如何在coredata上下文中使用预填充数据库 [英] How to use a pre-populated database on a coredata context
问题描述
这是我的第一个问题。
好吧,我开发一个iPhone应用程序,将使用coredata,但theres不会是一个选项插入数据进入应用程序的数据库。
我想知道如何预填充它的数据库。
想到创建一个plist与所有的信息,并使一个函数将其全部放入coredata数据库,如果数据库还没有设置...
但我想要非常感谢。
最简单的方法是创建一个具有相同模型的桌面应用程序(完全相同的模型,只是链接它)。然后让Interface Builder为它创建一个默认UI并输入数据。
一旦你有了数据,然后将SQLite文件包括在你的包中,因为你的应用程序是只读你的声明;将 NSPersistentStoreCoordinator
指向应用程式集中的档案,并指向Bob的叔叔。
在桌面上建立应用程式大约5分钟,并将在数据输入端节省更多的时间。
this is my first question here.
Well, I am developing an iPhone application that will use coredata, but the theres not going to be an option to insert data into the database of the app.
I want to know how to pre-populate it's database.
I thought of creating a plist with all the info and make a function to put it all into the coredata database if the database is not set yet...
but I want to know if it is the right way to do so.
Thanks all.
The easiest way is to create a desktop application with the same model (the exact same model even, just link it in). Then have Interface Builder create you a default UI for it and enter the data. Far easier than doing it on a device.
Once you have the data then include the SQLite file in your bundle and since your app is read only as you claimed; point the NSPersistentStoreCoordinator
at the file in your app bundle and Bob's your uncle.
Creating an app on the desktop takes about 5 minutes and will save you far more time on the data entry side.
这篇关于如何在coredata上下文中使用预填充数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!