restkit 개체 매핑을 사용하여 응답 json 데이터를 매핑하고 저장하려고합니다. 불행히도 나는 응답 데이터를 매핑 할 수 없다. 내가 datas를 저장하는 내 데이터베이스를 볼 수 있지만 내가 .. 다음과 같은 메시지가 충돌을 얻을 때이 클래스는 코딩 규격을 키Restkit iphone으로 매핑
출력 응답을 키 값이 아닌
{
"users": [
{
"id": "123456",
"ne": "JohnSmith",
"el": "[email protected]",
"dob": "1985/02/04",
"profile": {
"id": "654321",
"ht": "170cm",
"wt": "70kg"
}
}
]
}
내가 키 패스 (users.profile) 내가 사고를 얻고 여기에이
RKManagedObjectMapping *userProfileMapping = [RKManagedObjectMapping mappingForClass:[GHSUser class] inManagedObjectStore:manager.objectStore];
[userProfileMapping mapKeyPath:@"id" toAttribute:@"userId"];
[userProfileMapping mapKeyPath:@"ne" toAttribute:@"name"];
[userProfileMapping mapKeyPath:@"el" toAttribute:@"email"];
[userProfileMapping mapKeyPath:@"dob" toAttribute:@"dob"];
RKManagedObjectMapping *standardProfileMapping = [RKManagedObjectMapping mappingForClass:[GHSProfile class] inManagedObjectStore:manager.objectStore];
[standardProfileMapping mapKeyPath:@"id" toAttribute:@"userId"];
[standardProfileMapping mapKeyPath:@"ht" toAttribute:@"height"];
[standardProfileMapping mapKeyPath:@"wt" toAttribute:@"weight"];
[manager.mappingProvider setMapping:standardProfileMapping forKeyPath:@"users.profile"];
// 같은 매핑을 사용하지만, 프로필 정보는 DB에 삽입된다. 프로파일로 keypath를 변경하면 크래쉬가 발생하지 않지만 프로파일 세부 사항은 db에 삽입되지 않습니다.
[userProfileMapping mapRelationship:@"users" withMapping:standardProfileMapping];
오류 메시지 :
앱 종료* 의한 캐치되지 않는 예외 'NSUnknownKeyException'에 이유 '[< _NSObjectID_48_2 0x888a8d0>의 setValue : forUndefinedKey는 :] :이 클래스는 키 값, 코딩 아니다 핵심 프로필을 준수합니다. '
고맙습니다을 통해 UR 응답을
당신은 같은 줄을 변경하고 싶습니다. 사실 나는 배열에있는 모든 데이터가 db에 저장되기를 원합니다. 나는 마지막 코드를 이미 시도했다. 그러나 프로파일 데이터는 db에 삽입되지 않습니다. 사용자 데이터 만 저장하고 있습니다 – Anish
요청에 맞게 내 대답을 편집했습니다 –
위의 코드를 시도했지만 프로필 데이터가 삽입되지 않았습니다. – Anish