Re: CoreData and arrays owned by arrays...
Re: CoreData and arrays owned by arrays...
- Subject: Re: CoreData and arrays owned by arrays...
- From: mmalcolm crawford <email@hidden>
- Date: Tue, 17 May 2005 19:43:48 -0700
On May 17, 2005, at 7:22 PM, Lee Morgan wrote:
When working with CoreData I've noticed that there isn't really a
"sub array" style to the database - that is it seems like a pure
flat database...
I'm not sure what this means? It's up to you to define relationships
between entities...
I have a "master item" entity which contains a to-many relationship
to it's "sub item" entities. The sub items entities have a reverse
lookup (to-one relationship). This allows a sub item entity to
"belong" to a master item.
The problem I'm having is that in my GUI I have a table which shows
all master items. In this table I have a column which *should* show
all sub items of the corresponding master item. However I can't
find a proper key path to bind the table's pop up menu cell to the
arrangedObjects master items -> sub items.
How was this set up before you started using Core Data? In
particular, what were the bindings for the popup in the table view?
mmalc
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
- Prev by Date:
Re: getting the key window from another application
- Next by Date:
Re: How best to archive in CSV format If you haven't already solved this here is some code that may help. It does this for tsv files, tweaking it for csv files shouldn't be that much work. If you do mod this for csv, I'd love to get that code back, but it isn't required. Enjoy, -Mont Sorry, no docs. @interface NSArray (BNExtensions) - (NSArray *)tabJoinedComponents; - (NSString *)joinAsLinesOfEndingType:(LineEndingType)type; - (NSData *)dataWithLineEndingType:(LineEndingType)lineEndingType; @end @implementation NSArray (BNExtensions) - (NSArray *)tabJoinedComponents { NSEnumerator *components; NSMutableArray *rows; NSArray *row; components = [self objectEnumerator]; rows = [NSMutableArray arrayWithCapacity: [self count]]; while (row = [components nextObject]) { [rows addObject: [row componentsJoinedByString: @"\t"]]; } return rows; } - (NSString *)joinAsLinesOfEndingType:(LineEndingType)lineEndingType { switch (lineEndingType) { case LineEndingTyp! eDOS : return [self componentsJoinedByString: @"\r\n"]; case LineEndingTypeMac : return [self componentsJoinedByString: @"\r"]; case LineEndingTypeUnix : return [self componentsJoinedBy String: @"\n"]; default : return [self componentsJoinedByString: @""]; } } - (NSData *)dataWithLineEndingType:(LineEndingType)lineEndingType; { NSArray *rows; NSString *dataString; rows = [self tabJoinedComponents]; dataString = [rows joinAsLinesOfEndingType: lineEndingType]; return [dataString dataUsingEncoding: NSASCIIStringEncoding]; } @end @interface NSData (BNExtension) - (NSArray *)rowsAndColumns; @end @implementation NSData (BNExtension) - (NSArray *)rowsAndColumns { NSString *fileContents; NS_DURING fileContents = [[[NSString alloc] initWithData: self encoding: NSASCIIStringEncoding] autorelease]; NS_HANDLER fileContents = nil; [NSException raise: @"Import Error" format: @"There was a problem reading your file. Please make sure that it is a Tab delimited file. Additional information:\n\nException: %@\nReason: %@\nDetail: %@", [localException name], [localException reason], [localException userInfo]]; NS_ENDHANDLER return [[fileContents lines] valu! eForKey: @"tabSeparatedComponents"]; } @end typedef enum { LineEndingTypeNone = 0, LineEndingTypeDOS = 1, LineEndingTypeMac = 2, LineEndingTypeUnix = 3, } LineEndingType; @interface NSString (BNExtensions) - (NSArray *)lines; - (NSArray *)tabSeparatedComponents; - (NSArray *)rowsAndColumns; @end @implementation NSString (BNExtensions) - (LineEndingType)lineEndingType { NSRange lineEndRange; // Is this alineEndRangeDOS format? lineEndRange = [ self rangeOfString:@"\r\n"]; if (lineEndRange.location != NSNotFound) return LineEndingTypeDOS; // Not DOS; is this the Mac format? lineEndRange = [self rangeOfString:@"\r"]; if (lineEndRange.location != NSNotFound) return LineEndingTypeMac; // Not DOS or Mac, is this Unix format? lineEndRange = [self rangeOfString:@"\n"]; if (lineEndRange.location != NSNotFound) return LineEndingTypeUnix; // This string has a single line return LineEndingTypeNone; } - (NSArray *)lines { LineEndingType lineEndingType; lineEndingType = [self lineEndingType]; switch (lineEndingType) { case LineEndingTypeDOS : return [self componentsSeparatedByString: @"\r\n"]; case LineEndingTypeMac : return [self componentsSeparatedByString: @"\r"]; case LineEndingTypeUnix : return [self componentsSeparatedByString: @"\n"]; default : return [NSArray arrayWithObject: self]; } } - (NSArray *)tabSeparatedComponents { return [self componentsSeparatedByString: @"\t"]; } - (NSArray *)rowsAndColumns { re! turn [[self lines] valueForKey: @"tabSeparatedComponents"]; } @end
- Previous by thread:
CoreData and arrays owned by arrays...
- Next by thread:
Re: CoreData and arrays owned by arrays...
- Index(es):