Map upper keypath to lower keypath mapping attribute RESTKIT V0.20

馋奶兔 提交于 2019-12-11 22:17:40

问题


"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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!