带有 CoreData 的 iPhone 应用程序 [英] iPhone app with CoreData

查看:49
本文介绍了带有 CoreData 的 iPhone 应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我打算创建一个使用 CoreData 的 iphone 应用程序.稍后可能会在应用程序的新版本中添加增强功能.我的问题是;使用CoreData时,要注意哪些因素才能保证用户升级版本后,之前的数据完好无损?就像我听说我们应该保持 .sqlite 文件名相同.在发布 Core Data 应用程序时,还有哪些其他因素需要牢记?

I am planning to create an iphone app which uses CoreData. There might be enhancements added later as new versions of the app. My question is; When using CoreData, what are the factors to keep in mind to ensure if the user upgrades the version, his previous data remains intact ? Like I heard we should keep the.sqlite file name same. What are other factors to keep in mind while releasing Core Data apps?

谢谢.

推荐答案

如果您打算长期维护数据迁移概念,了解数据迁移概念很重要,因为您最终可能希望至少更改某些内容.

Data migration concepts are important to understand if you're going to maintain it over time, since you're likely to want to change at least some things eventually.

理想的是轻量级迁移,从旧数据模型到新数据模型的微小转换是自动的.如文档中所述,如果您的更改是:

The ideal is Lightweight Migration, where minor conversion from your old data model to your new one is automatic. As noted in the document, it can take care of itself if your changes are:

  • 简单地添加一个新属性
  • 非可选属性变为可选
  • 可选属性变为非可选,并定义默认值

重命名实体或属性也很容易且几乎是自动的.

Renaming an entity or an attribute is also easy and nearly automatic.

除此之外的一切——新的或移除的实体,新的或移除的或改变的关系——都是毛茸茸的.这并不是非常困难,但肯定是更多的工作,有更多的失败空间.

Everything beyond that -- new or removed entities, new or removed or changed relationships -- is hairier. It's not incredibly difficult, but it's definitely more work, with more room for failure.

因此,对可能的潜在变化进行一些推测可能会使提前提供一点回旋余地更容易、更有效.显然,如果你做得太多,尤其是在理论上但目前未使用的关系上,你可能会无缘无故地减慢当前系统的速度.

As such, a little speculation about likely potential changes may make it easier and more efficient to provide a little wiggle room in advance. Obviously if you do too much, especially with theoretical-but-currently-unused relationships, you're likely slowing down the current system and potentially for no reason.

值得考虑.

这篇关于带有 CoreData 的 iPhone 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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