我正在使用RestKit与核心数据,并且无法映射实体之间的关系。问题是我有3个不同的jsons(3个不同的屏幕),这些jsons有相互关联的数据。我的3个实体是发布,对话和消息。关系如此:每篇文章都有很多对话(对多关系),每个对话都有很多信息(对多关系)。与关系的RestKit问题
这里是桩的阵列的第一JSON:
{"success":true,"result":
[{"totalUsers":1,"lastMessageDate":1411612821000,"id":874,"title":"My post title"},
{"totalUsers":3,"lastMessageDate":1411536669000,"id":539,"title":"Message me"}]}
这里是第二JSON,这是对话的特定交的数组:
{"success":true,"result":
[{"badgeSize":1,"lastMessage":
{"id":1725,"text":"hey","datePublished":141153372347},"id":208,"username":"energydrink"}]}
这里是第三json进行特定会话:
{"success":true,"result":
{"spamStatus":false,"messages":
[{"id":416,"text":"hello","datePublished":1403432789000},
{"id":380,"text":"whats up","datePublished":1403432144221}]}}
因此,您可以看到,关系的数据是分成3个jsons。下面是我所目前RestKit中配置我的人际关系和响应描述:
[conversationMapping addPropertyMapping:[RKRelationshipMapping relationshipMappingFromKeyPath:@"messages" toKeyPath:@"messages" withMapping:messageMapping]];
[postMapping addPropertyMapping:[RKRelationshipMapping relationshipMappingFromKeyPath:@"conversations" toKeyPath:@"conversations" withMapping:messageMapping]];
RKResponseDescriptor *responseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:postMapping method:RKRequestMethodAny pathPattern:nil keyPath:@"result" statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)];
因为响应描述符与postMapping映射,我无法正确地映射为第2和数据3 jsons然后核心数据中存储与我的配置。任何帮助是极大的赞赏。