Re: CoreData and arrays owned by arrays...
Re: CoreData and arrays owned by arrays...
- Subject: Re: CoreData and arrays owned by arrays...
- From: email@hidden
- Date: Wed, 18 May 2005 17:49:31 +0000
-------------- Original message --------------
> I'm not sure if this might be the problem, but ... are you binding
> to your NSArrayController's contentArray or are you using the
> mutableSet binding? For Core Data to-many relationships, you have to
> use the mutableSet binding since to-many relationships are
> represented by sets, not arrays.
I bind to set, not array. But I believe the underlying problem is the same. Best I can tell I can't create an array (using bindings) from the mutableSet of the to-many relationship, which seems like a requirement in-order to popuplate the pop up menu.
- lee
_______________________________________________
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: NEWBIE: Why use protocols?
- Next by Date:
Re: CoreData and arrays owned by arrays...
- Previous by thread:
Re: CoreData and arrays owned by arrays...
- Next by thread:
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
- Index(es):