I need a little help about KVC.
Few words about the operating context:
1) The iPhone connects (client) to a webService to get an object,
2) I'm using JSON to transfer data,
3) If the client has exactly the same object mapping I can iterate through the NSDictionary from JSON to store the data in the permanent store (coreData). To do that I'm using this code fragment (assume that are all data are NSString):
NSDictionary *dict = ... dictionary from JSON
NSArray *keyArray = [dict allKeys]; //gets all the properties keys form server
for (NSString *s in keyArray){
[myCoreDataObject setValue:[dict objectForKey:s] forKey:s]; //store the property in the coreData object
}
Now my problem ....
4) What happen if the server implementing a new version of the object with 1 new property If I transfer the data to the client and the client is not at the save version level (it means is still using the "old" object mapping) I'll try to assign a value for a non existing key... and I will have the message:
the entity "myOldObject" is not key value coding-compliant for the key "myNewKey"
Could you suggest me how to test for the existence of the key in the object so, if the key exists, I'll can proceed to the value update avoiding the error message ?
Sorry if I have been a little confusing in my context explanation.
Thanks
Dario