我正在使用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然後核心數據中存儲與我的配置。任何幫助是極大的讚賞。