ios - Restkit entity relationship from two different responses based on url params -


i have 2 different urls:

/getposts 

and

/getcommentsforpost?postid={id} 

with these responses:

{   "post": {     "postid":1,     "title":"lorem ipsum"   } } 

and

{   "comment" : {     "commentid" : 123,     "text" : "lorem ipsum"   } } 

as can see, comment object doesn't have postid property.

and these questions:

  1. is possible create entity relationships between responses 2 different requests via restkit , core data?
  2. how (and when) can read postid second url , set in comment model?

  1. yes, use foreign key mapping.
  2. you set of metadata use during mapping ('metadata mapping' in doc).

your life more difficult because id query parameter rather being part of url path more restful. might need have restkit map url or url query (@metadata.http.request.url.query) , have transient attribute reads appropriate information data.


Comments