iosobjective-ctableviewrestkit

RestKit 0.20 nested object mapping trouble using API


I'm getting the titleForHeaderInSection correctly, where its pulling the leaf.

But getting nothing for themes.

I'm guessing my mapping to themes is not working, because cellForRowForIndexPath doesn't seem to be getting called when I set breakpoints.

But obviously I'm not sure and that's why I'm looking for some guidance.

API JSON

{
    "springs": [{
        "name": "baskets",
        "leafs": [{
            "name": "New Season",
            "abbreviation": "nb",
            "themes": [{
                "name": "Hops",
                "abbreviation": "HS",
}          

 

ViewController.h

@property (strong, nonatomic) NSArray *springs;
@property (strong, nonatomic) NSMutableArray *leafs;
@property (strong, nonatomic) NSMutableArray *themes;

Solution

  • This line

      [springMapping addPropertyMapping:[RKRelationshipMapping relationshipMappingFromKeyPath:@"themes" toKeyPath:@"themes" withMapping:themeMapping]];
    

    Should be

      [leafMapping addPropertyMapping:[RKRelationshipMapping relationshipMappingFromKeyPath:@"themes" toKeyPath:@"themes" withMapping:themeMapping]];
    

    Because the theme is nested inside leaf (which is itself nested inside spring).