I recently ran into this problem. Tracing through RestKit looks like an attempt to apply all object mappings to all relationships in an RKDynamicMapping instance. See applyRelationshipMappings in RKMappingOperation.m
I came up with a solution that is a hack, but did not require me to change the backup code much.
In RKMappingOperation.m, I changed the following method:
destinationObjectForMappingRepresentation:parentRepresentation:withMapping:inRelationship:
I added the following code (starting with a comment) that checks to see if the assignment of the relationship is the same type of object that is applied, and only continues if it matches. (This has not been rigorously tested, but works in my particular use case.)
- (id)destinationObjectForMappingRepresentation:(id)representation parentRepresentation:(id)parentRepresentation withMapping:(RKMapping *)mapping inRelationship:(RKRelationshipMapping *)relationshipMapping { RKObjectMapping *concreteMapping = nil; if ([mapping isKindOfClass:[RKDynamicMapping class]]) { concreteMapping = [(RKDynamicMapping *)mapping objectMappingForRepresentation:representation]; if (! concreteMapping) { RKLogDebug(@"Unable to determine concrete object mapping from dynamic mapping %@ with which to map object representation: %@", mapping, representation); return nil; }
...
John baldwin
source share