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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to