问题
"Allocation":{
"UserID":"8bc2df34-b77a-4889-a2ab-559e24cc2d40",
"Answers":
{
"SurveyInstanceAnswerID":"cb924a6a-ad61-4786-b5fb-00302c4fc7dc",
"SurveyInstanceAllocationID":"42e96cec-5a00-416c-8a96-488ab152e4f5",
"AllocationUniqueRef":"1ce53cdf-b33e-4594-a938-b60656b8b64c",
"SurveyContentID":"ccd07464-9718-4953-8e51-ad25fa00e053",
"AnswerValue":null,
}
}
I have two classes Allocation with userID and answer with answervalue and userID.
I want to map userid present in allocations with userid in answer class.
I am using rkEntitymapping to map objects
回答1:
If you use the current development branch (at the time of writing this feature hasn't been merged back to the master branch) you can use metadata to access the parent object during the mapping process:
@metadata.mapping.parentObject
So you can add a mapping:
@"@metadata.mapping.parentObject.UserID" : @"userId"
来源:https://stackoverflow.com/questions/18485014/map-upper-keypath-to-lower-keypath-mapping-attribute-restkit-v0-20