问题:
Attempt to set a non-property-list object{...}as an NSUserDefaults value for key shop.
解决办法:
if you don't want to bother about ensuring all your dictionary values are the property list types, then you can simply convert the dictionary into NSData,
NSUserDefaults *def = [NSUserDefaults standardUserDefaults]; [def setObject:[NSKeyedArchiver archivedDataWithRootObject:self.myDictionary] forKey:@"MyData"]; [def synchronize];
And to get back into a dictionary from sandbox:
NSUserDefaults *def = [NSUserDefaults standardUserDefaults]; NSData *data = [def objectForKey:@"MyData"]; NSDictionary *retrievedDictionary = [NSKeyedUnarchiver unarchiveObjectWithData:data]; self.myDictionary = [[NSDictionary alloc] initWithDictionary:retrievedDictionary];
Hope this helps someone.