我正在开发一个 iOS 应用程序。我有一个扩展 NSObject 的类,它定义了 1 个属性
//.h file
@property (nonatomic,retain) NSMutableDictionary *livedata;
//.m file
if(self = [super init]){
self.livedata = [[NSMutableDictionary alloc] init];
[self.livedata setValue:@"myvalue" forUndefinedKey:@"myUndefinedKey"];
}
我收到这个错误。 *由于未捕获的异常“NSUnknownKeyException”而终止应用程序,原因:“[setValue:forUndefinedKey:]:此类与键 myUndefinedKey 的键值编码不兼容。”
我过去曾将 NSMutableDictionary 用于 kvc、kvo。是的,我看到该类不符合 kvc。