Re: CoreData problem - AttributeDescription seems invalid --- Where am I wrong?
Re: CoreData problem - AttributeDescription seems invalid --- Where am I wrong?
- Subject: Re: CoreData problem - AttributeDescription seems invalid --- Where am I wrong?
- From: Quincey Morris <email@hidden>
- Date: Wed, 01 Jun 2011 21:10:47 -0700
On Jun 1, 2011, at 13:26, Motti Shneor wrote:
> - (NSMutableDictionary *)attributesAsDictionary {
> NSMutableDictionary *attributesDictionary = [NSMutableDictionary dictionaryWithCapacity:[self.entity.attributesByName count]];
> for (NSAttributeDescription* attribute in self.entity.attributesByName ) {
> NSString *attribName = [attribute name];
> id attribValue = [self valueForKey:attribName];
> if (attribName && attribValue)
> [attributesDictionary setObject:attribValue forKey:attribName];
> }
> return attributesDictionary;
> }
>
> Running this for a nice entity that I just Saved (validated) and Fetched again --- the method crashes horribly on the NSString *attribName = [attribute name];
>
> If I step inside with the debugger, I see things I can't understand. I get into the loop, and for the first attribute ---
> 1. Debugger claims attribute type is CFStringRef * instead of NSAttributeDescription*
You have to read the documentation. 'attributesByName' returns a dictionary, and enumerating a dictionary with 'for (... in ...)' enumerates the dictionary keys, which are indeed strings in this case.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden