0
我正在嘗試設置在NSMutableDictionary
值,但我總是收到此錯誤:的iOS:不能設置爲空值的一個NSMutableDictionary
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<__NSDictionaryI 0x10fd55990> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key image.'
在的NSMutableDictionary我有一個@"image"
場那可以是null
。我想用佔位符圖片名稱替換null
值。 這是我要做的事:
NSMutableDictionary * item = self.carouselSource[index];
if([Utils isNull:[item valueForKey:@"image"]]) {
[item setValue:@"default_image.png" forKey:@"image"];
}
但由於錯誤的應用程序崩潰這一行
[item setValue:@"default_image.png" forKey:@"image"];
以上。
使用'快enumration' –
你的字典裏是不變的 - 這是一個'NSDictionary'而不是'NSMutableDictionary'。欲瞭解更多信息,你可以從[這裏](https://stackoverflow.com/questions/14731353/nsdictionaryi-setobjectforkey-unrecognized-selector-sent-to-instance) –
@ Anbu.Karthik檢查我的編輯請 –