Dhruv Goel
Dhruv Goel

Reputation: 2765

Restkit seed core-data with objects from a local file on launch

I'm working on an app, in which I need to seed core-data with some local data stored in a file and I'm using Restkit.

Right now, I have stored the data in JSON format in a text file, and on launch I use the "RKManagedObjectImporter" to map the JSON to objects. Since the data is huge, it takes a lot of time (at least 30 seconds) just to map the data from JSON to Core-data objects.

I obviously cannot make the user wait 30 seconds on the first launch, and the data is required as soon as the app launches. So what alternative do I have here ? Is there a way to create mapped objects and store them in a file ?

Any help will be appreciated!

Upvotes: 1

Views: 717

Answers (1)

Wain
Wain

Reputation: 119021

You can create a Core Data .sqlite file and distribute it with the app instead of a JSON file. Then, when the app launches you can check if the user has an existing store file and, if not, copy the default file from the bundle into the desired location.

RestKit also offers importing support using a .sqlite source file, see here.

Upvotes: 2

Related Questions