使用API​​,RestKit 0.20嵌套对象映射问题

时间:2014-04-13 02:04:55

标签: ios api tableview restkit

我正确地获得了titleForHeaderInSection,其中提取了leaf

themes没有得到任何内容。

我猜测我的映射到themes无法正常工作,因为在我设置断点时cellForRowForIndexPath似乎没有被调用。

但显然我不确定,这就是我寻找指导的原因。谢谢!

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;

1 个答案:

答案 0 :(得分:5)

这一行

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

应该是

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

因为主题嵌套在leaf中(它本身嵌套在spring中)。