Skip to content

Instantly share code, notes, and snippets.

@koloritcm
Last active December 17, 2015 20:49
Show Gist options
  • Save koloritcm/5670284 to your computer and use it in GitHub Desktop.
Save koloritcm/5670284 to your computer and use it in GitHub Desktop.
Sharing parent value when mapping a list of objects
// {
// "category": "MyCategory"
// "items": [
// { "id": 1, "name": "A" },
// { "id": 2, "name": "B" },
// { "id": 3, "name": "C" }
// ]
// }
// Current mapping, but missing "category" object that should be mapped to each "Item"
RKEntityMapping *mapping = [RKEntityMapping mappingForEntityForName:@"Item" inManagedObjectStore:manager.managedObjectStore];
mapping.identificationAttributes = @[ @"id" ];
[mapping addAttributeMappingsFromDictionary:@{ @"name": @"name" }];
// TODO: Also add "category" to this mapping
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment