거의 동일한 제목의 이전 질문과 동일한 문제가 아니기 때문에 다음 단계를 밟았습니다.Magical Record import (다음 단계)
나는 Person
엔티티가 있습니다.
Person
--------
name - mappedKeyName: FullName
email - mappedKeyName: EmailAddress
personID - mappedKeyName: Id
--------
photos
그리고 Photo
엔티티.
Photo
--------
image
createDate - mappedKeyName: Date
photoID - mappedKeyName: Id
--------
owner (type Person) - mappedKeyName: UserId - relatedByAttribute: personID
너무 Person
에 관련된 다른 개체가 있고 이들에 대한 JSON 내 설정 가져 오기와 함께 작동이 JSON으로 ... 그래서
{
ObjectId : blah,
Owner : {
Id : 12345asdfg,
FullName : Oliver,
EmailAddress : [email protected]
}
}
온다. 존재하지 않는 사람 기록 (Id 포함)이 생성됩니다. 그리고 존재하는 것은 업데이트됩니다.
그러나, 사진 JSON 객체는 객체가 같은 내려와 때 그 사람의 수입에 도달 할 때 마법 기록 가져 오기가 중지 ...
{
Id : thisIsThePhotoID,
Date : today,
UserId : 12345asdfg
}
과 같이 제공됩니다. 코드는에 충돌
...
- (id) MR_relatedValueForRelationship:(NSRelationshipDescription *)relationshipInfo
{
NSString *lookupKey = [self MR_lookupKeyForRelationship:relationshipInfo];
return lookupKey ? [self valueForKeyPath:lookupKey] : nil; // it stops here.
}
lookupKey
의 값은 @ "personID". 브레이크 포인트가 제공에서 relationshipInfo을 인쇄
...
$6 = 0x1fd695e0 (<NSRelationshipDescription: 0x1fd695e0>),
name owner,
isOptional 0,
isTransient 0,
entity Photo,
renamingIdentifier owner,
validation predicates(),
warnings(),
versionHashModifier (null)
userInfo {
mappedKeyName = UserId;
relatedByAttribute = personID;
},
destination entity Person,
inverseRelationship photos,
minCount 1,
maxCount 1,
isOrdered 0,
deleteRule 1
난 정말이 작동하지 않는 이유를 모르겠어요. 나는 현명 오류를보고하지 않습니다.
우수 답변! 매우 감사합니다. 가져 오기가이 형식으로 작동하지 않는다고 말하는 사람이 가장 먼저 나옵니다. (이전의 세 가지 질문은 모두 "처음 일하는 것"이라고 대답했습니다.) 내일 다시 돌아와서 솔루션을 구현하려고합니다. 다시 한번 감사드립니다. – Fogmeister
@ Fogmeister 내가 어떻게 도움이되는지 궁금한 점이 있으면 알려주십시오. – runmad
@ Fogmeister 문제를 해결하는 데 도움이되었는지 궁금합니다. – runmad