iOS [NSKeyedUnarchiver initForReadingWithData:]: data is NULL?

释放双眼,带上耳机,听听看~!

解决方法:

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

        // unarchive the value here

 }

2、NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults];

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

[defaults synchronize];

 

人已赞赏
iOS文章

iOS reason: '*** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array'

2020-5-8 2:48:01

iOS文章

Xcode编译报错XCTest/XCTest.h file not found

2020-5-8 4:03:18

个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
有新消息 消息中心
搜索