启动时在Core Data中填写信息。 [英] Prefill information in Core Data at startup.
问题描述
我必须做一个使用核心数据存储信息的iOS应用程序。
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.
我如何做?
推荐答案
查看一些示例应用程序,如iPhone 核心数据图书。基本上你使用你的应用程序发送一个预填充的数据库,在初始启动时,你的应用程序委托使用你在数据库中填充的数据将它复制到应用程序的Documents目录中。
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.
这篇关于启动时在Core Data中填写信息。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!