【发布时间】:2016-03-09 04:13:20
【问题描述】:
{
"id": 76,
"name": "Tom Timberley",
"gender": 1,
"follower_count": 1,
"following_count": 1,
"me_following": [{
"id": 5,
"status": "ACCEPTED",
"following_me": {
"id": 2,
"status": "ACCEPTED"
}
}]
}
没有外部 Json 对象。当我做RKRelationshipMapping 时,有什么方法可以从对象following_me 访问根对象?
我有表Following_me 和User,我想将作为用户数据的Json 的根映射到Following_me。
[following_me_mapping addPropertyMapping:[RKRelationshipMapping relationshipMappingFromKeyPath:@"@root" toKeyPath:@"user" withMapping:userMapping]];
这里following_me_mapping 是Following_me 表的映射,userMapping 是User 表的映射。
但指定 @root 不起作用。
[RKResponseDescriptor responseDescriptorWithMapping:mapping
method:RKRequestMethodGET
pathPattern:nil
keyPath:nil
statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)
];
这就是我添加响应描述符的方式。
【问题讨论】: