所以,我正在使用 AFPhotoEditorController,它有一个名为 AFPhotoeditorSession 的属性,用于存储和跟踪所有用户操作。这个会话类是从 NSObject 继承的自定义对象,我已经搜索了如何在 NSUser Defaults 中保存自定义对象并来到知道如果该类符合协议 NSCoding 我们可以保存该类,我不知道我是否可以更改该类,因为它只是我在 AviarySDk 的自定义框架中拥有的.h 文件。
NSData *myEncodedObject = [NSKeyedArchiver archivedDataWithRootObject:
[self.sessions objectAtIndex:0]]; // self.session an array of one object of AFPhotoeditorSession
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:myEncodedObject forKey:@"myEncodedObjectKey"];
[defaults synchronize];
NSData *data1 = [defaults objectForKey:@"myEncodedObjectKey"];
AFPhotoEditorSession *obj = (AFPhotoEditorSession *)[NSKeyedUnarchiver unarchiveObjectWithData: data1];
NSLog(@"%@",obj);
我收到如下错误:
*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<AFPhotoEditorSession 0x1c5fa0f0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key modified.'
您可以在PhotoEditorSession中查看 AFPhotoEditor Session 类