I am trying to map and store a response json data using restkit object mapping. unfortunately i cannot able to map a response data. when i view my database the datas are storing, but i get a crash with following message.. this class is not key value coding-compliant for the key
Output response
{
"users": [
{
"id": "123456",
"ne": "JohnSmith",
"el": "[email protected]",
"dob": "1985/02/04",
"profile": {
"id": "654321",
"ht": "170cm",
"wt": "70kg"
}
}
]
}
I am using mapping like this
RKManagedObjectMapping *userProfileMapping = [RKManagedObjectMapping mappingForClass:[GHSUser class] inManagedObjectStore:manager.objectStore];
[userProfileMapping mapKeyPath:@"id" toAttribute:@"userId"];
[userProfileMapping mapKeyPath:@"ne" toAttribute:@"name"];
[userProfileMapping mapKeyPath:@"el" toAttribute:@"email"];
[userProfileMapping mapKeyPath:@"dob" toAttribute:@"dob"];
RKManagedObjectMapping *standardProfileMapping = [RKManagedObjectMapping mappingForClass:[GHSProfile class] inManagedObjectStore:manager.objectStore];
[standardProfileMapping mapKeyPath:@"id" toAttribute:@"userId"];
[standardProfileMapping mapKeyPath:@"ht" toAttribute:@"height"];
[standardProfileMapping mapKeyPath:@"wt" toAttribute:@"weight"];
[manager.mappingProvider setMapping:standardProfileMapping forKeyPath:@"users.profile"];
//here in keypath(users.profile) i am getting crash,but profile details are inserting in db. when i change keypath to profile, i am not getting any crash but profile details are not inserting in db.
[userProfileMapping mapRelationship:@"users" withMapping:standardProfileMapping];
Error Message:
* Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<_NSObjectID_48_2 0x888a8d0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key profile.'