I think I'm getting close, but still running into some errors that I can't seem to get past. In summary:
{
"parents": [
{
"id": "1",
"children": [{"id:"1"},{"id":"2"}],
"name": "Bob"
},
{
"id": "2",
"children": [{"id:"1"}],
"name": "Joan"
}
],
"children": [
{
"id": "1",
"name": "Johnny"
},
{
"id": "2",
"name": "Suzy"
}
]
}
MAPPINGS:
RKEntityMapping *parentMapping = [RKEntityMapping mappingForEntityForName:@"Parent" inManagedObjectStore:managedObjectStore];
parentMapping.identificationAttributes = @[@"id"];
[parentMapping addAttributeMappingsFromArray:@[@"id", @"name"]];
RKEntityMapping *childMapping = [RKEntityMapping mappingForEntityForName:@"Child" inManagedObjectStore:managedObjectStore];
childMapping.identificationAttributes = @[@"id"];
[childMapping addAttributeMappingsFromArray:@[@"id", @"name"]];
RELATIONSHIP CONNECTION:
[parentMapping addConnectionForRelationship:@"children" connectedBy:@{@"children": @"id"}];
RESPONSE DESCRIPTORS:
RKResponseDescriptor *parentResponseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:parentMapping pathPattern:@"/api/everything" keyPath:@"parents" statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)];
RKResponseDescriptor *childResponseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:childMapping pathPattern:@"/api/everything" keyPath:@"children" statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)];
[objectManager addResponseDescriptorsFromArray:@[parentResponseDescriptor, childResponseDescriptor]];
The error I am getting is this:
'Cannot connect relationship: invalid attributes given for source entity 'Parent': children'
I have Core Data objects for both Parent and Child with a "children" relationship (to-many) from parent to child (and inverse specified on the child).
I think that I'm really close, but nothing I try seems to work. Suggestions?