Created
September 21, 2014 08:50
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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