iOS [NSKeyedUnarchiver initForReadingWithData:]: data is NULL?

来源:互联网 发布:螺纹铣刀铣内螺纹编程 编辑:程序博客网 时间:2024/05/17 23:49

解决方法:

1if ([[[NSUserDefaults standardUserDefaults] dictionaryRepresentation].allKeys containsObject:@"keyForNonMandatoryObject"]) {

        // unarchive the value here

 }

2NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults];

[defaults setObject:[NSKeyedArchiver archivedDataWithRootObject:myObject] forKey:@"MyObjectKey"]; 

[defaults synchronize];

0 0
原创粉丝点击