Any way to pre populate core data?

Tanner picture Tanner · Feb 9, 2010 · Viewed 38.7k times · Source

I've been creating a list app and backing it with core data.

I would like to have a default list of say 10 airport's items, so that the user doesn't have to start from scratch.

Is there any way to do this?

Any help is appreciated. Thanks in advance.

Answer

Ken Aspeslagh picture Ken Aspeslagh · Feb 10, 2010

Here's the best way (and doesn't require SQL knowledge):
Create a quick Core Data iPhone app (Or even Mac app) using the same object model as your List app. Write a few lines of code to save the default managed objects you want to the store. Then, run that app in the simulator. Now, go to ~/Library/Application Support/iPhone Simulator/User/Applications. Find your application among the GUIDs, then just copy the sqlite store out into your List app's project folder.

Then, load that store like they do in the CoreDataBooks example.