KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm using RestKit and i want to parse and save elements to core data. I have two json files: First (Category): [ { "cat_id": 3371, "cat_name": "myName", "image": 762 }, { "cat_id": 3367, "cat_name": "anotherName", "image": 617 } ] And second (Elements): [ { "art_id": "1", "node": { "author": "name" }, "small_url": 0 }, { "art_id": "12", "node": { "author": "anotherName" }, "small_url": 0 } ] So the basic idea is that every category have some elements inside. So this is my CoreData struct: I've download the restkit example and use TwitterCoreData sample. My code is: AppDelegeta.m - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { NSURL *baseURL = [NSURL URLWithString:@"http://globalURL.com"]; RKObjectManager *objectManager = [RKObjectManager managerWithBaseURL:baseURL]; NSManagedObjectModel *managedObjectModel = [NSManagedObjectModel mergedModelFromBundles:nil]; RKManagedObjectStore *managedObjectStore = [[RKManagedObjectStore alloc] initWithManagedObjectModel:managedObjectModel]; objectManager.managedObjectStore = managedObjectStore; RKEntityMapping *categoryMapping = [RKEntityMapping mappingForEntityForName:@"Category" inManagedObjectStore:managedObjectStore]; categoryMapping.identificationAttributes = @[ @"catId" ]; [categoryMapping addAttributeMappingsFromDictionary:@{ @"cat_id": @"catId", @"node.author": @"author", }]; RKEntityMapping *elementsMapping = [RKEntityMapping mappingForEntityForName:@"Elements" inManagedObjectStore:managedObjectStore]; elementsMapping.identificationAttributes = @[ @"artId
Tags (comma-separated)
Save Edits
Cancel