Core Data와 함께 RestKit을 사용하고 있는데 엔티티 간의 관계를 매핑하는 데 문제가 있습니다. 문제는 내가 3 개의 서로 다른 화면에 대해 3 개의 서로 다른 jsons를 가지고 있으며이 jsons에는 상호 연관된 데이터가 있습니다. 나의 3 엔티티는 포스트, 대화 및 메시지입니다. 관계는 다음과 같습니다. 각 게시물에는 많은 대화 (일대일 관계)가 있고 각 대화에는 많은 메시지 (일대일 관계)가 있습니다. 여기 관계가있는 RestKit 문제
{"success":true,"result":
[{"totalUsers":1,"lastMessageDate":1411612821000,"id":874,"title":"My post title"},
{"totalUsers":3,"lastMessageDate":1411536669000,"id":539,"title":"Message me"}]}
특정 게시물 대화 배열 인 제 2 JSON이다 : 여기서
는 포스트의 어레이에 대한 제 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 센트로 나눠.
[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을지도하고 코어 데이터 내에 저장 드릴 수 없습니다 : 저는 여기에 현재 RestKit 내에서 내 관계와 응답 디스크립터를 구성하는 방법입니다 내 구성으로. 어떤 도움이라도 대단히 감사합니다.