I'm trying to set a value in an NSMutableDictionary
but I'm always getting this error:
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<__NSDictionaryI 0x10fd55990> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key image.'
In the NSMutableDictionary I have an @"image"
field that can be null
. I want to replace the null
value with a placeholder image name.
This is how I do it:
NSMutableDictionary * item = self.carouselSource[index];
if([Utils isNull:[item valueForKey:@"image"]]) {
[item setValue:@"default_image.png" forKey:@"image"];
}
But the application crash in this line
[item setValue:@"default_image.png" forKey:@"image"];
due to the error above.