I am mapping with simple json response,
{
"town": "ABC",
"website": "http://xyz.com",
"fee": "50.00",
"event_id": 32,
"images": [
{
"large": "1.jpg",
"thumbnail": "2.jpg"
},
{
"large": "1.jpg",
"thumbnail": "2.jpg"
},
{
"large": "1.jpg",
"thumbnail": "2.jpg"
}
]
}
and my mapping function look like this
RKManagedObjectMapping *eventMapping = [RKManagedObjectMapping mappingForClass:[Events class] inManagedObjectStore:manager.objectStore];
[eventMapping mapKeyPath:@"town" toAttribute:@"town"];
[eventMapping mapKeyPath:@"website" toAttribute:@"website"];
[eventMapping mapKeyPath:@"fee" toAttribute:@"fee"];
[eventMapping mapKeyPath:@"event_id" toAttribute:@"event_id"];
eventMapping.primaryKeyAttribute = @"event_id";
[manager.mappingProvider setMapping:eventsMapping forKeyPath:@""];
RKManagedObjectMapping *imagesMapping = [RKManagedObjectMapping mappingForClass:[Images class] inManagedObjectStore:manager.objectStore];
[imagesMapping mapKeyPath:@"large" toAttribute:@"large"];
[imagesMapping mapKeyPath:@"thumbnail" toAttribute:@"thumbnail"];
[eventsMapping mapKeyPath:@"images" toRelationship:@"images" withMapping:imagesMapping];
But i am not to make a relationship successfully. My Db is always showing empty relationship b/w images and events. i tried connectrelationship, but i think i need primary key for images table to make a connection. can anyone guide me to correct way of doing this.
Do i need to add primary key for Images table or is it possible to access the 'event_id' from parent table (event) and use it for making relations.
xcodetag. - user529758iOSthaniPhone- HAS