I am making an iPhone app that gets data from a web service and stores it in Core Data. All these properties have keys to identify them in a dictionary. I have an NSObject class of all the properties.
I have now decided to add one more property not being gotten from a web service called checkMark. I have also added it to this method. The problem is whenever I try and set the checkMark property in a method like this : [s setValue:[NSNumber numberWithInt:check] forKey:@"checked"];, s being a managedObject I get an error saying "the entity Course is not key value coding-compliant for the key "checked". How do I fix this?
- (id)initWithDictionary:(NSDictionary *)dictionary
{
self = [super init];
if (self) {
// Set the property values
_iD = [[dictionary valueForKey:@"Id"] intValue];
_isCurrent = [[dictionary valueForKey:@"IsCurrent"] boolValue];
_checkMark = [[dictionary valueForKey:@"checked"] intValue];
}
}
You need to make the entity Course key value coding-compliant for the key “checked”.
https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/KeyValueCoding/Articles/Compliant.html
Basically that means it must have a setter
setChecked:and a getterchecked. The usual thing is to have a property with synthesis of that setter and getter.Incidentally, the fact that the log message is talking about an entity Course suggests to me that the thing you are calling
dictionaryand casting as an NSDictionary might in fact not be a dictionary at all, but might be something else, i.e. an NSManagedObject. Just a guess… You might do some logging / breakpointing to see what’s really happening here.