I have a managed object lets say products and I have another object that getting the data from another server and is already stored as managed object. There's nothing you in terms of the JSON data you get from the server that you can relate the two objects together. The only way is to do it manually before you get send the request. Is there a way to create a relationship that can do that using Restkit?
Asked
Active
Viewed 27 times
0
-
What is the request URL (presumably it has some unique identifier in it)? – Wain Mar 26 '15 at 10:50
-
it generally doesn't have any information about the object who requested it. But I can inject an id into the request and getting that as a field in result if it's something we can work with – MKoosej Mar 26 '15 at 15:49
1 Answers
0
If you have the unique identifier of the source object in the request path or somewhere in the response body then you can use it in the mapping and perform a foreign key mapping to connect a relationship between the source and response objects.
If the identity is in the request path then you need to use RKRoute
to prepare the request and @metadata.routing.parameters
in your mapping to extract the identity. If it's in the response body then the standard mapping approach applies.
Once you have it, you map it into a temporary attribute on your destination object.
Once you have that you can perform your foreign key mapping.