Question

Ok, I am admittedly pretty new to core data, and am still not quite as knowledgeable as I would like to be. I am doing some pretty basic data retrieval from the database using values that I went in and added myself (using the sqlite editor Base).

I got everything working in my simulator, and I thought that life was just dandy but I went in and installed the app on my 2g iPod touch, and when my pickerview went to go get data...there wasn't anything there! I guess it's not terribly surprising, but I was thinking that the app build would just copy the db that I had setup??

What is going on? What do I need to do to make it so that the pre-loaded data is available for any and all downloaders of my app?

Thanks!

Was it helpful?

Solution

The core data persistent store won't get automatically added to your app. You will need to add this file to your project so that it becomes part of the app bundle when you build the app. You can see what will happen in xcode after you've added this file under your target settings.

Additionally apple discourages modification of the SQLite data store directly outside of core data. You may be better off just using SQLite in that case. If you feel you really need core data, you may want to make a default SQLite database that is part of your app. The first time the app is run (or the data is reset) you can then import that data into your user's custom core data persistent store. See this portion of apple's documentation on how to import an existing SQLite database into core data. This allows you to have default data but gives you the flexibility of being able to reset the database easily.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top