I\'m trying to make the magic happen with RestKit and Rails. I\'m using Rails 3.1.1, and RestKit 0.9.3 (not the master branch). I am using Core Data in my iOS app, so I\'m
I think the inverseMapping
selector should be enough to make a serialization mapping
RKManagedObjectMapping *listMapping = [RKManagedObjectMapping mappingForClass:[List class]];
listMapping.primaryKeyAttribute = @"listID";
[listMapping mapAttributes:@"title", nil];
[listMapping mapKeyPath:@"id" toAttribute:@"listID"];
[manager.mappingProvider setMapping:listMapping forKeyPath:@"list"];
//this should be enough
[manager.mappingProvider setSerializationMapping:[listMapping inverseMapping] forClass:[List class]];
Edit:
according to our chat conversation, the warnings produced by RestKit were caused by the fact that the server response was lacking the root KeyPath (returned as naked array). To solve the problem we need to tell RestKit to use specific mapping to map the response:
mapping = [[[RKObjectManager sharedManager] mappingProvider] mappingForKeyPath:@"list"];
[[RKObjectManager sharedManager] postObject:newList mapResponseWith:mapping delegate:self];
This is from the RestKit docs. There is a convenience method that sets both mapping and serialization mapping
[[RKObjectManager sharedManager].mappingProvider registerMapping:mapping withRootKeyPath:@"person"];
This will call setMapping:forKeyPath: for you, then generate a serialization mapping and set the root keyPath as well.