0
votes

I'm extremely stuck on mapping a simple JSON object:

{"articles":
[{"id":"354633","lat":"51.501","lng":"-0.125","type":"railwaystation","title":"Westminster tube station","url":"http:\/\/en.wikipedia.org\/w\/index.php?curid=354633","distance":"53m"},

{"id":"92601","lat":"51.5011","lng":"-0.125","type":"railwaystation","title":"17  - Westminster tube station","url":"http:\/\/en.wikipedia.org\/w\/index.php?   curid=92601","distance":"62m"},    

{"id":"92598","lat":"51.5011","lng":"-0.125","type":"railwaystation","title":"34 -Westminster tube station","url":"http:\/\/en.wikipedia.org\/w\/index.php?curid=92598","distance":"62m"}]
}

I'm really puzzled by the problem I'm having, since this is almost identical to the JSON in the RestKit Mapping Guide.

My code is:

self.articleMapper = [RKObjectMapping mappingForClass:[WikiArticle class]];
[self.articleMapper mapKeyPath:@"title" toAttribute:@"title"];    
[[RKObjectManager sharedManager].mappingProvider setMapping:self.articleMapper forKeyPath:@"articles"];

I'm getting the following error in the log:

restkit.object_mapping:RKObjectMappingOperation.m:339 Did not find mappable attribute value keyPath 'title'
restkit.object_mapping:RKObjectMappingOperation.m:557 Mapping operation did not find any mappable content
restkit.object_mapping:RKObjectMapper.m:308 The following operations are in the queue: ()
restkit.object_mapping:RKObjectMapper.m:323 Finished performing object mapping. Results: {}

Thanks in advance for helping me out with something so simple -- I've been banging my head against it for hours!

-Alex

1

1 Answers

0
votes

I suppose you call it in a way like this:

[objectManager loadObjectsAtResourcePath:url delegate:self block:^(RKObjectLoader* loader) {
        loader.objectMapping = [objectManager.mappingProvider objectMappingForClass:[WikiArticle class]];
    }];

Better try:

[objectManager loadObjectsAtResourcePath:url delegate:self];