在 iPhone 应用程序中,我有一个NSDictionary
对象,其键为NSString
,值是自定义对象。我正在尝试将其转换NSData
为 iCloud。我这样做了:
NSMutableData *data = [NSMutableData data]; NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:data]; [archiver encodeObject:myDictionary forKey:@"mykey"]; [archiver finishEncoding];
现在,encodeObject 行抛出了这个异常(NSDictionary
对象'myDictionary'中有值。我检查了。):
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ConnectionProfile encodeWithCoder:]: unrecognized selector sent to instance 0x1f849350'
ConnectionProfile 是我作为值存储在NSDictionary
. 它应该NSCoding
明确实施吗?