在 iPhone 上使用 CoreData 或 SQLite? [英] Use CoreData or SQLite on iPhone?

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

问题描述

既然 CoreData 在 OS 3.0 中已可用于 iPhone,它是否意味着要成为数据持久性的答案并取代对直接 SQLite 的所有需求?

Since CoreData has become available for the iPhone in OS 3.0, is it meant to be the answer to data persistence and replace all need for direct SQLite?

仍然使用 SQLite 的原因是什么?SQLiteCoreData 的优缺点是什么?

What reasons exist to still use SQLite? What are advantages/disadvantages of SQLite vs. CoreData?

推荐答案

这是一个常见问题:

总而言之,Core Data 可以极大地简化您的代码,尤其是对于复杂的对象模型.您几乎可以免费获得撤消/重做支持.它还提供了一些非常重要的性能优势,尤其是在 iPhone 上.尽管这看起来违反直觉,但考虑到您认为该框架有多少开销,在大多数情况下,您可以击败使用 Core Data 手动调整的 SQLite 的性能.在 iPhone 上,它在批量获取以最大限度地减少内存使用方面做得很好.

In summary, Core Data can greatly simplify your code, particularly for complex object models. You get undo / redo support almost for free with it. It also provides some very significant performance benefits, particularly on the iPhone. Even though it seems counterintuitive, given how much overhead you'd think the framework has, in most cases you can beat the performance of hand-tuned SQLite using Core Data. On the iPhone, it does a great job of batching fetches to minimize memory usage.

正如所指出的,一个缺点是这限制了您,因为您的最终用户需要 iPhone OS 3.0.然而,这对我的用户来说根本不是问题,而且只会越来越少.

The one downside, as pointed out, is that this limits you by requiring iPhone OS 3.0 for your end users. However, this has not been a problem at all for my users, and will only become less of one going forward.

这篇关于在 iPhone 上使用 CoreData 或 SQLite?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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