Skip to content

Instantly share code, notes, and snippets.

@quellish
Created September 21, 2014 08:50
Show Gist options
  • Select an option

  • Save quellish/760f19e8682dc78caae4 to your computer and use it in GitHub Desktop.

Select an option

Save quellish/760f19e8682dc78caae4 to your computer and use it in GitHub Desktop.
Remapping JSON keys to Core Data attributes using the userInfo dictionary of the attribute entity description as defined in the Core Data Model Editor
entityUserInfo = [entity userInfo];
reKeyedValues = [[NSMutableDictionary alloc] initWithDictionary:jsonObject];
for (NSString *key in keyedValues){
if ([entityUserInfo valueForKey:key] != nil){
[reKeyedValues setValue:[keyedValues valueForKey:key] forKey:[entityUserInfo valueForKey:key]];
// Remove the original key
[reKeyedValues setValue:nil forKey:key];
}
}
[managedObject setValuesForKeysWithDictionary:reKeyedValues];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment