2

I am developing a simple iOS 9 app (using Swift and Xcode 7.01) that uses a Timehop style interface to show data corresponding to the current day, going back X number of years.

I want to seed my CoreData model on first runtime, populating it with specific data based on user chosen options at this first runtime (or changed later in user preferences). However, I would like my entire data source imported so that different data is available if the user preferences are changed

My current data source to be migrated to CoreData is currently in CSV format. My question is, what is the easiest file format to work with for importing/seeding into CoreData, are there any best practices to follow when performing such a task, and is there a right direction I can go in to work out the implementation?

m.s.
  • 16,063
  • 7
  • 53
  • 88
d5automations
  • 419
  • 1
  • 6
  • 13

1 Answers1

8

Ideally you want to do any preloading during the building of your application rather than at runtime. You can easily pre-create your Core Data sqlite file and ship it with the application bundle. Then you can either access all of the data or create multiple sqlite files to fit the specific needs of your application.

With the data shipped with the application bundle you can then simply copy the correct sqlite file from the app bundle once you know which one to use and completely avoid having to parse the data at runtime.

Parsing large amounts of data at runtime is a waste of the user's time and should be avoided.

Do it during the build.

Your users will thank you.

Marcus S. Zarra
  • 46,571
  • 9
  • 101
  • 182