RestKit/RestKit — comment on commit 700456c8eb17b5c7f4677fe8827beafe261b8521
File:  line 0
By lightforce:

It doesn't quite work for me, I have the following setup:

-(RKManagedObjectMapping*)itemMapping {
RKManagedObjectMapping* itemMapping = [RKManagedObjectMapping mappingForClass:[Item class]];
[itemMapping mapAttributes:@"entityID",@"itemID",@"amount",@"type", nil];
itemMapping.primaryKeyAttribute = @"entityID";
return itemMapping;
}
-(RKManagedObjectMapping*)journeyMapping {
RKManagedObjectMapping* journeyMapping = [RKManagedObjectMapping mappingForClass:[Journey class]];
[journeyMapping mapAttributes:@"entityID",@"timeStamp", nil];
[journeyMapping mapRelationship:@"items" withMapping:[self itemMapping]];
journeyMapping.primaryKeyAttribute = @"entityID";
journeyMapping.setNilForMissingRelationships = YES;
journeyMapping.setDefaultValueForMissingAttributes = YES;
return journeyMapping;
}

Test:

RKObjectMappingProvider* provider = [RKObjectManager sharedManager].mappingProvider;
RKObjectMapping* mapping = [provider objectMappingForClass:[Journey class]].inverseMapping;
RKObjectSerializer* serializer = [RKObjectSerializer serializerWithObject:object mapping:mapping];
NSError* error = nil;
id serialization = [serializer serializationForMIMEType:@"application/json" error:&error];

NSString* data = [[NSString alloc] initWithData:[serialization HTTPBody] encoding:NSUTF8StringEncoding];
data = [data stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSLog(@"%@",data);

Produces

{"items":{"type":[],"itemID":[],"amount":[],"entityID":[]}}

Instead of

{"items":[]}