Is it possible to force the Mapper of a RestKit to map a specific nested object in an array using mapKeyPath syntax?
Here is the answer I'm trying to display
<result is_array="true">
<item>
<_field_data>
<nid>
<entity>
<field_region>
<und is_array="true">
<item>
<value>1</value>
</item>
</und>
</field_region>
....
I'm only interested in the first element that will ever be returned for field_region.
What is the correct way to match this?
I tried various iterations:
RKManagedObjectMapping *record = [RKManagedObjectMapping mappingForClass:[MyRecordClass class] inManagedObjectStore:objManager.objectStore];
[record mapKeyPath:@"_field_data.nid.entity.field_region.und.0.item.value" toAttribute:@"region"];
and I keep getting errors similar to:
T restkit.object_mapping:RKObjectMappingOperation.m:152 Found transformable value at keyPath '_field_data.nid.entity.field_region.und.0.item.value'. Transforming from type '__NSArrayI' to 'NSNumber'
W restkit.object_mapping:RKObjectMappingOperation.m:232 Failed transformation of value at keyPath '_field_data.nid.entity.field_region.und.0.item.value'. No strategy for transforming from '__NSArrayI' to 'NSNumber'
I invoke the mapping through:
[[RKObjectManager sharedManager] loadObjectsAtResourcePath:kMyResourcePath usingBlock:^(RKObjectLoader* loader) {
loader.objectMapping = [[RKObjectManager sharedManager].mappingProvider objectMappingForClass:[MyRecordClass class]];
loader.method = RKRequestMethodGET;
loader.delegate = self;
loader.targetObject = nil;
}];
Any ideas? Most valuable!
Ted source
share