为核心数据应用提供基本数据? [英] Provide Base Data for Core Data Application?

查看:100
本文介绍了为核心数据应用提供基本数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用一个Core Data应用程序(对于iPhone 3.0,虽然我不认为这在真正有区别),它将需要配备一个初级数据库填充数据。使用SQLite,我只需让应用程序将填充的数据库从捆绑包复制到应用程序的文档目录首次启动,然后加载该数据库 - 所有的信息将随之而来,我们将准备好去。但是对于Core Data,我不太确定我是否可以将Persistent存储保存到App bundle并在Core Data开始做它之前复制它。这会造成任何问题吗?有相当多的初始数据,所以我不想把它以另一种格式打包,并且必须通过它解析。

I'm working on a Core Data app (for iPhone 3.0, though I don't think that really makes a difference here) and it will need to ship with a "starter" database filled with data. With SQLite, I would just have the App copy the populated database from the bundle into the App's documents directory on first launch and then load that database - all the information would come along with it and we'd be ready to go. But with Core Data, I'm not really sure if I can just save the Persistent store to the App bundle and copy it before having Core Data start doing its thing. Will this cause any problems? There is quite a bit of initial data, so I don't want to package it in another format and have to parse through it.

推荐答案

是的,您可以复制预填充的永久存储。

Yes, you can copy over a pre-populated persistent store.

我创建了一个填充商店的Mac应用程序。它被复制到我的包,开始时,复制到Docs目录。这工作正常。我被告知Core Data Books示例是以相同的方式开发的。

I created a Mac app that populates a store. It is copied into my bundle and at start, copied to the Docs directory. This works fine. I am told the Core Data Books example was developed the same way.

请注意,这并不意味着你可以复制任何旧的SQLite文件。它必须是一个核心数据持久存储,但我认为你理解,基于你的问题。

Please note this doesn't mean you can just copy over any old SQLite file. It has to be a Core Data persistent store, though I think you understand that based on your question.

这篇关于为核心数据应用提供基本数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆