在Core Data持久存储中运送静态(只读)数据的正确方法是什么? [英] What's the correct way to ship static (read-only) data in Core Data persistent store?
问题描述
我想要发送静态只读数据,以便在Core Data模型中使用。问题是,有明显不同的持久存储类型,我不知道这些类型的格式是否应该是不透明的,或者如果我应该能够手工构建它们。
I want to ship static read-only data for use in my Core Data model. The problem is that there are obviously different persistent store types and I don't know if the format of those types is supposed to be opaque or if I'm supposed to be able to construct them by hand.
现在我只有一个plist,它非常小(可能总共30个条目)。
Right now I just have a plist and it's very small (maybe 30 entries total).
我应该写代码导入plist在我的数据存储中,当应用程序是第一次安装,或者有一些方法,我可以运送一个手工构建的数据存储文件的初始版本?
Should I just write code to import the plist into my data store when the app is first installed, or is there some way I can ship a hand-constructed initial version of the data store file?
使用默认的sqlite持久存储。)
(I'm using the default sqlite persistent store.)
推荐答案
我不会试图手工构建它,并保存最终的Core Data SQLite文件以与您的应用程序一起发布。
I would not try to hand-construct it, but you certainly should execute an import and save a final Core Data SQLite file to ship with your app.
我计划编写一个小的mac实用程序(使用相同的数据模型)生成Core Data SQLite文件(我的iPhone应用程序的导入实际上是从Web服务器)。然后,我将添加该实用程序持久化的文件到我的iPhone应用程序的项目。
I plan to write a small mac utility (using the same data model) to generate the Core Data SQLite file for my iPhone app (the import is actually from a web server). Then, I will add the file that was persisted by the utility into my iPhone app's project.
这篇关于在Core Data持久存储中运送静态(只读)数据的正确方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!