I need to relate entities using foreign id's downloaded form a web server. I have an event - category (one event has on category, and one category has many events). A web service to GET all categories, and a second web service to GET all events.
This are the json's returned by the web services:
categories:
[
{ "id" : "1",
"name" : "music",
},
{ "id" : "2",
"name" : "sports",
},
{ "id" : "3",
"name" : "meetup"
}
]
events:
[
{ "category_id" : "1",
"description" : "free concert",
"id" : "7791"
},
{ "category_id" : "2",
"description" : "Running event",
"id" : "8357"
}
]
I am saving category_id on my Events entity (RestKit mapping for both entities work fine).
Right now, to show the event's category I need to take the category_id and do a fetch request to core data, instead of using a getter (event.category.categoryID).
Is there a way to configure RestKit (and/or CoreData) to relate this two entities after doing a GET of the events? I'm using RestKit 0.20.3.