I have a rest webservice that gets me the a json response in the following structure :
{
"Categories": [
{
"category_id":1,
"category_name":"category 1"
},
{
"category_id":2,
"category_name":"category 2"
}
],
"Products":[
{
"product_id":1,
"product_name":"Product 1",
"category_id":1
},
{
"product_id":2,
"product_name":"Product 2",
"category_id":1
},
{
"product_id":3,
"product_name":"Product 3",
"category_id":2
}
]
}
I am creating a Core data model for my iOS application in which i can save this data as you can see below .
The problem is how can I use the relationships that I have created in my core data model to map this data?
The silliest idea that comes to my mind is to search for each product's category based on the category id and then set it like Product.category = category [i] , but there got to be a easier way to do this.