Reputation: 808
I've gone through a few days of pain using RestKit to map some JSON. Being new to Core Data I made the assumption that once RestKit had mapped the data to my RestKit created DB, i.e.
objectManager.objectStore = [RKManagedObjectStore objectStoreWithStoreFilename:@"EFrontCD.sqlite"];
I could leave the RestKit world. I then attempted to load my data into a UITableViewController implementing the RKManagedObjectStore protocol and doing the usual stuff, but I get the error
UIManagedDocument can only read documents that are file packages
2 questions:
Thanks, Ben
Upvotes: 2
Views: 1254
Reputation: 1183
Seems that your missing some general understanding how Core Data works. Feel free to read this tutorials to improve your knowledge about it.
Core Data always uses a data storage (this can be a SQLite, XML, ...) and when you're telling RestKit to use the SQlite as the objectStore, it will.
To get the data inside you'll have to use fetch requests and link to the ManagedObjectContext which is a kind of handler between the data storage and your data.
Upvotes: 0
Reputation: 808
Answering the first part of my question, this is what I was looking for:
RKObjectManager *objectManager = [RKObjectManager sharedManager];
objectManager.objectStore.managedObjectContextForCurrentThread
Once you have access to the MOC RestKit has created for you, then everything appears to be the same - I can do the usual Core Data stuff.
I'm still not clear about the second question, but would certainly like to know if this is possible.
Upvotes: 2