{
"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对象。当我following_me
时,有什么办法可以从对象RKRelationshipMapping
访问根对象吗?
我有表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)
];
这是我添加响应描述符的方式。
答案 0 :(得分:0)
也许你可以使用“MJExtension.Framework”来表示“json to model”数据(https://github.com/CoderMJLee/MJExtension),将这些数据显示在模型而不是json数据(字典)上可以简化你的问题,祝福!〜 〜
答案 1 :(得分:0)
@media print {
body * {
visibility: hidden;!important;
}
#gmap {
position: absolute; !important;
left: 0;
top: 0;
}
}
答案 2 :(得分:0)
您似乎在向后思考问题,并对您的响应描述符处理的内容感到困惑。
通过设置pathPattern:nil keyPath:nil
,您的响应描述符将对您所做的任何请求都有效(它不会被路径模式过滤)并且将从根处理JSON有效负载(没有关键路径导航到)。
因此,您的初始映射已经应该处理根。然后,您为me_following
键添加关系以处理该内容。在该映射中,您可以为following_me
添加关系。
通过这种方式,您可以向下钻取数据映射,而不是您想要深入研究的描述,然后尝试再次导航(这需要一种相当不同且更复杂的方法)。