简体   繁体   English

Coredata性能—运送预填充的核心数据sqlite db以获取只读数据集

[英]Coredata performance — shipping prepopulated core data sqlite db for readonly data set

i am thinking to create a pre-populate core data sqlite file and copy to my resources. 我正在考虑创建一个预填充的核心数据sqlite文件并复制到我的资源中。 And use it instead of creating a database from scratch on first run. 并使用它而不是在第一次运行时从头开始创建数据库。

My data is readonly and will not be modified by iphone app. 我的数据是只读的,不会被iPhone应用程序修改。

Database will be updated may be once in a month. 数据库可能每月更新一次。 So is it okay that for updating I get the updated coredata sqlite db via http request and discard the previous one and start using the updated one. 因此,对于更新,我可以通过http请求获取更新的coredata sqlite db,并丢弃前一个,并开始使用更新的。 This approach will also save me hassle for migration and other stuff 这种方法还可以节省迁移和其他工作的麻烦

Please suggest, if this approach seems okay 如果这种方法可行,请提出建议

Yes, your idea seems ok, but there is one problem. 是的,您的想法似乎不错,但是有一个问题。

Files in the main app bundle are readonly, thus you can't update the sqlite file. 主应用程序捆绑包中的文件为只读文件,因此您无法更新sqlite文件。

What you can do is when you create the coredata store file, check wether the file is in the document director. 您可以做的是在创建coredata存储文件时,检查文件是否在Document Director中。 If it is not there copy the file from the bundle there and then create the managedstore. 如果不存在,请从捆绑包中复制文件,然后创建托管存储。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM