NSUserDefaults:Attempt to insert non-property value Objective C
2014-09-04 22:28
393 查看
问题:
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,
And to get back into a dictionary from sandbox:
Hope this helps someone.
参考:
http://stackoverflow.com/questions/15857408/attempt-to-insert-non-property-value-objective-c
http://stackoverflow.com/questions/23186021/nsuserdefaults-setobjectforkey-attempt-to-insert-non-property-list-object
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];[/code]
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];[/code]
Hope this helps someone.
参考:
http://stackoverflow.com/questions/15857408/attempt-to-insert-non-property-value-objective-c
http://stackoverflow.com/questions/23186021/nsuserdefaults-setobjectforkey-attempt-to-insert-non-property-list-object
相关文章推荐
- NSUserDefaults:Attempt to insert non-property value Objective C
- NSUserDefaults 存数据 Attempt to insert non-property list object
- iOS使用NSUserDefaults 存储数据报Attempt to set a non-property-list object as an NSUserDefaults value的错误解决
- 错误:*** -[NSUserDefaults setObject:forKey:]: attempt to insert non-property list object
- *** -[NSUserDefaults setObject:forKey:]: Attempt to insert non-property value ‘<Student: 0x8399f70>’
- Attempt to set a non-property-list object as an NSUserDefaults
- iOS NSUserDefaults数据保存报错:Attempt to set a non-property-list object...
- NSUserDefaults数据保存报错:Attempt to set a non-property-list object...
- [User Defaults] Attempt to set a non-property-list object () as an NSUserDefaults/CFPreferences valu
- Attempt to set a non-property-list object null as an NSUserDefaults
- [User Defaults] Attempt to set a non-property-list object
- Attempt to insert non-property list object - 芒果iOS
- [User Defaults] Attempt to set a non-property-list object
- NSInvalidArgumentException', reason: '-[__NSCFDictionary setObject:forKey:]: attempt to insert nil value (key: WebKitLocalStorageDatabasePathPreferenc
- Attempt to set a non-property-list object
- Attempt to set a non-property-list object 报错问题
- could not be set to a 'string' value. You must set this property to a non-null value of type
- The property on could not be set to a 'Int16' value.You must set this property to a non-null value of type ‘Int32’.”
- Attempt to set a non-property-list object
- Attempt to set a non-property-list object