Prefill information in Core Data at startup.
I have to do an iOS application that used core data to store the information.
I created the model and how to add data into the application, everything is working perfect, the only 开发者_开发百科problem I have is that, the data model is empty, but I wanted to fill automatically with some data when the application is startup.
How can I do?
Take a look at some of the sample apps, like the iPhone Core Data Books. Basically you ship a pre-filled database with your app, and on initial startup your app delegate copies it into the application's Documents directory, using the data you populated in the database.
As I recall, you can't start with a pre-built data store with Core Data--you'll have to create your store on first run.
Apple's tips and tricks for this initial import can be found here. 98% of the time, it's best to just follow along with their docs.
精彩评论