0
개체 OrganizationalUnit은 부모 ID 속성을 통해 상위 엔터티에 연결되어 있습니다. OrganizationalUnit에는 기본 키 속성 ouId (JSON "_id"필드에서 매핑 됨)이 있습니다. RestKit에서 발견 된 예와 동일한 방식으로 작동ID를 참조하여 RestKit 매핑 객체
RKManagedObjectMapping *ouMapping = [RKManagedObjectMapping mappingForClass:[OrganizationalUnit class] inManagedObjectStore:manager.objectStore];
[ouMapping mapAttributes:@"name",@"type", nil];
[ouMapping mapKeyPath:@"_id" toAttribute:@"ouId"];
[ouMapping setPrimaryKeyAttribute:@"ouId"];
[ouMapping mapKeyPath:@"parent" toAttribute:@"parentId"];
[ouMapping hasOne:@"parent" withMapping:ouMapping];
[ouMapping connectRelationship:@"parent" withObjectForPrimaryKeyAttribute:@"parentId"];
: 로컬 ID를 기반으로 객체 사이의 관계를 만들어야합니다
RKManagedObjectMapping* taskMapping = [RKManagedObjectMapping mappingForClass:[Task class] inManagedObjectStore:objectStore];
taskMapping.primaryKeyAttribute = @"taskID";
[taskMapping mapKeyPath:@"id" toAttribute:@"taskID"];
[taskMapping mapKeyPath:@"name" toAttribute:@"name"];
[taskMapping mapKeyPath:@"assigned_user_id" toAttribute:@"assignedUserID"];
[objectManager.mappingProvider setMapping:taskMapping forKeyPath:@"task"];
// Hydrate the assignedUser association via primary key
[taskMapping hasOne:@"assignedUser" withMapping:userMapping];
[taskMapping connectRelationship:@"assignedUser" withObjectForPrimaryKeyAttribute:@"assignedUserID"];
이 내 코드입니다.
*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<__NSCFString 0x6d9c6f0> valueForUndefinedKey:]: this class is not key value coding-compliant for the key _id.'
어떤 생각 : 런타임에서 불행하게도
, 수신 된 데이터의 실제 매핑이 일어나는 때, 나는 오류가?
매핑하려는 JSON을 게시 할 수 있습니까? 나는 RestKit과 비슷한 문제를 겪었고 해결책을 찾지 못했습니다 (http://stackoverflow.com/questions/13054112/mapping-relationships-in-restkit-through-an-array-of-ids-doesnt-work 참고).) – gummihaf