NSUserDefaults Croaks on Dictionary Containing NSNumber as Key
NSUserDefaults Croaks on Dictionary Containing NSNumber as Key
- Subject: NSUserDefaults Croaks on Dictionary Containing NSNumber as Key
- From: Jerry Krinock <email@hidden>
- Date: Fri, 11 Dec 2009 23:10:59 -0800
Sorry for the wonky subject. It's easier to explain in code:
NSNumber* innerKey = [NSNumber numberWithInt:0] ;
NSDictionary* dic = [NSDictionary dictionaryWithObject:@"Hello"
forKey:innerKey] ;
[[NSUserDefaults standardUserDefaults] setObject:dic
forKey:@"outerKey"] ;
Result:
*** -[NSUserDefaults setObject:forKey:]: Attempt to insert non-property value '{
0 = Hello;
}' of class 'NSCFDictionary'.
If I change innerKey to a string such as @"0", then all works fine.
In my opinion, after reading the documentation carefully, this exception is a false alarm. First of all, NSCFDictionary *is*, as required, one of the "property list" objects: NSData, NSString, NSNumber, NSDate, NSArray, or NSDictionary. Furthermore, all of its objects and keys are themselves property list objects. Furthermore, NSNumber conforms to NSCopying protocol, as required for dictionary keys.
Is there some other requirement that I missed?
Jerry Krinock
_______________________________________________
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