I am initializing a NSManagedObject subclass using:
- (void)setValuesForKeysWithDictionary:(NSDictionary *)keyedValues
I am also knowingly giving it the undefined keys, which of course should through an exception.
So, I have implemented:
- (void)setValue:(id)value forUndefinedKey:(NSString *)key
If a key is undefined, I map it to the correct key.
However, my implementation never gets called, instead NSManagedObject's implementation is used, which in turn still throws an exception.
Is there a behavior (or bug) that prevents setValuesForKeysWithDictionary: from using any NSManagedObject subclass implementation of setValue:forUndefinedKey:?
Adding code as requested, but since I am just implementing an existing method, which doesn't get called, I don't know how much help it will be:
In the context:
- (Company*)companyWithDictionary:(NSDictionary*)values{
Company* newCompany = (Company*)[NSEntityDescription insertNewObjectForEntityForName:@"Company" inManagedObjectContext:self];
[newCompany setValuesForKeysWithDictionary:values];
return newCompany;
}
In the Company subclass (never called):
- (void)setValue:(id)value forUndefinedKey:(NSString *)key{
if([key isEqualToString:idKey]){
[self setValue:value forKey:@"uniqueID"];
}else if([key isEqualToString:descriptionKey]){
[self setValue:value forKey:@"descriptionText"];
}else if([key isEqualToString:timeUpdatedKey]){
[self setValue:value forKey:@"dateUpdated"];
}else{
[super setValue:value forUndefinedKey:key];
}
}