Take the 2-minute tour ×

I have a relatively small amount of data (stored in a static text file) that I'm loading into Core Data in my iOS app. What is the fastest or preferred method of storing static data on the device and loading data into Core Data?

I've tried putting the data in XML format and using libxml to load it into Core Data. I've also tried putting the data in CSV format and using basic string parsing to load it into Core Data. Both of these methods seem to take about the same amount of time for a given data set. I noticed a minor load-time reduction by putting the call to NSManagedObjectContext save outside of the loop over the rows (or XML nodes depending on the format).

Please note the data is only loaded the first time the app starts. Also I've tried "create a SQLite db using another utility app then bundle the SQLite db with the current app" based on feedback from this question. However I couldn't get that to work. If that's the best way to do this then I'll try again.


share|improve this question

1 Answer 1

up vote 1 down vote accepted

The simplest solution is to load the data into a Core Data persistent SQL store during development. Then include that file in the app bundle itself. Upon first launch, copy the file from the readonly app bundle into the Documents or Library directory. Then open the store as normal. All the data will be in place and ready to go.

share|improve this answer
Ok I'll try this. When I tried last time I didn't copy the bundled file to the Documents or Library directory. –  MrDatabase Jun 10 '11 at 23:52

Your Answer


