The short answer is no - key-value encoding does not allow this. Only aggregated operations, such as max, min, avg, sum, are supported for collection.
It is best to add the NSArray property to NOSearchResult:
// NOSearchResult definition @interface NOSearchResult : NSObject @property(retain) NSString* place_id; @property(retain) NSString* latitude; @property(retain) NSNumber* longitude; @property(retain) NSArray* coordinates; @end @implementation NOSearchResult @synthesize place_id, latitude, longitude, coordinates; @end
and define the mapping as follows:
RKObjectMapping* resultMapping = [RKObjectMapping mappingForClass:[NOSearchResult class]]; [resultMapping mapKeyPath:@"id" toAttribute:@"place_id"]; [resultMapping mapKeyPath:@"position" toAttribute:@"coordinates"];
After that, you can manually assign latitude and longitude from the coordinates.
EDIT: A good place to assign latitude / longitude, probably in object loader delegates
- (void)objectLoader:(RKObjectLoader*)objectLoader didLoadObject:(id)object;
and
- (void)objectLoader:(RKObjectLoader*)objectLoader didLoadObjects:(NSArray*)objects;
Victor K.
source share