更新应用程序以使用来自以前的双SQLite只持久存储的核心数据 [英] Updating Application to use Core Data from previous double SQLite only persistent store

查看:144
本文介绍了更新应用程序以使用来自以前的双SQLite只持久存储的核心数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在升级旧的iPhone闪存卡应用程序,使用两个SQLite dbs(一个只读问题,只能通过应用程序更新,删除卡,添加卡,更新卡,以及另一个用户添加了自己的自定义卡)来使用Core Data。区分只读卡和用户添加卡的Flashcard对象的唯一属性是isCustom属性。以下是我认为必须执行此操作的步骤:

I'm currently upgrading an older iPhone flashcard application that uses two SQLite dbs (one with read-only questions that can only be updated by app updates, deletion of cards, addition of cards, updates to cards, and another one where user added their own custom cards) to use Core Data instead. The only property for the "Flashcard" object that distinguishes between a read only card and user added card is the "isCustom" property. Here are the steps that I believe are necessary to do this:

(从2个SQLite dbs到CoreData的第一次更新)

(First update from 2 SQLite dbs to CoreData)


  1. 从用户自定义卡db获取所有自定义卡条目。

  2. 使用只读卡添加新的Core Data对象模型,然后

  3. 删除旧的SQLite数据库(自定义卡数据库和只读卡
    db)。
  1. Get all custom card entries from the user custom card db.
  2. Add new Core Data object model with read only cards, and then load in user added custom cards to this model.
  3. Delete old SQLite databases (custom card db and read only card db).


    (未来更新将具有核心数据模型)

(Updates in the future that will already have a Core Data model)



  1. 将所有自定义卡片迁移到新的Core Data持久存储。

我只是想确保,如果这是我去开始设计这个系统之前的方式。非常感谢任何提示。

I just want to make sure if this is the way to go before I start designing this system from the ground up. Any tips will be greatly appreciated.

推荐答案

没有理由不能保留两个Core Data存储:仅适用于您的应用程序随附的内容,以及可对您的自定义条目进行写入的内容。我在我的一个应用程序中这样做,它允许我轻松更新每个版本的数据库。

There's no reason that you can't still maintain two Core Data stores: one read-only for your content that you ship with your application, and one that's writable for your custom entries. I do this within one of my applications, and it allows me to easily update the database I ship with each version.

我管理我的两个不同的永久存储在不同的上下文,但您也可以将多个持久性存储附加到同一持久性存储协调器,以使它们都在同一上下文中。

I manage my two different persistent stores under separate contexts, but you can also attach multiple persistent stores to the same persistent store coordinator to have them both be on the same context.

请注意,如果您使用相同的模型 - 只有Core Data持久存储,或将只读数据包含在一个中央持久存储中,每次更新时,还需要将非自定义数据迁移到新模型。使用您的应用程序发送单独的只读Core数据存储将允许您在结束时执行一次迁移,而不是让每个最终用户在模型更新的字段中执行迁移。

Note that if you use the same model for your read-only Core Data persistent store, or include the read-only data in one central persistent store, you'll also need to migrate that non-custom data to the new model every time you update that. Shipping a separate read-only Core Data store with your application would let you do that migration once on your end, rather than having each one of your end users do that migration in the field on a model update.

这篇关于更新应用程序以使用来自以前的双SQLite只持久存储的核心数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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