How to unarchive data with unarchivedObjectOfClass:fromData:error:?

前端 未结 2 1522
感情败类
感情败类 2021-01-05 03:30

I am using unarchiveObjectWithData to unarchive data from NSUserDefaults and it is working good, but it was deprecated in iOS 12.0. Xcode suggests

2条回答
  •  情话喂你
    2021-01-05 04:07

    I faced up with an issue and follow the @Darren answer, but unarchivedObjectOfClass returns nil ! :(

    so i tried a lot of variation and found the only success way is my case:

    supportsSecureCoding property must be YES

    and

    NSArray *arrayOfCustomObjects = [NSKeyedUnarchiver unarchivedObjectOfClass:[NSObject class] fromData:data error:&error];
    

提交回复
热议问题