core data 与 hibernate

本文对比了CoreData与SQLite在iOS应用开发中的使用情况。CoreData作为Cocoa API的一部分,简化了数据管理流程,提供了高级的数据操作接口。而SQLite则为直接的关系型数据库系统,适合跨平台使用。对于简单的数据库读取需求,可以使用FMDB等Objective-C封装库。CoreData更适合复杂的数据操作场景。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Core DataMac OS XCocoa API的一部分,首次在Mac OS X 10.4 TigeriOS 3.0系统中出现[2]。它允许按照实体-属性-值模型组织数据,并以XML二进制文件SQLite数据文件的格式将其串行化。Core Data允许用户使用代表实体和实体间关系的高层对象来操作数据。它也可以管理串行化的数据,提供对象生存期管理与object graph管理,包括存储。Core Data直接与SQLite交互,避免开发者使用原本的SQL语句[3]

就像Cocoa绑定模型-视图-控制器设计中做了很多控制器的工作一样,Core Data做了很多数据模型的工作。它的主要任务是负责数据更改的管理,串行化到磁盘,最小化内存占用,以及查询数据。

object-relational mapper (ORM) hibernate也是 orm框架,

Core Data isn't so much a database engine as it is an API that abstracts over the actual data store. You can tell Core Data to save as an sqlite database, a plist, a binary file, or even a custom data store type.

I would recommend learning Core Data, as is it an excellent resource that greatly accelerates many parts of cocoa application development.

要不要用 core data,

Prior to the release of OS 3.0 on the iPhone, SQLite was the choice for database implementation on the iPhone.  Since the addition of core data to the iPhone SDK, using SQLite with low level C function calls is no longer the only option, and now a question often asked is about which to use.

First, let’s take a look at using SQLite directly.

- Relational Database System
- Potential for cross platform compatibility
- Many early iPhone database examples were written using SQLite
- Objective-C wrappers such as FMDB are pretty easy to use

Now at Core Data:

- Can store data in it’s own Binary, or SQLite storage format.
- Can serialize objects
- Much higher level than using SQLite directly
- Not a RDBMS you could actually just store things directly.

Now the real question is, which is easier to use?  Well, that really depends on what you’re doing.  In an app I recently created all I had to do was read small amounts of data sequentially from a SQLite database, since this is such a simple task I simply used FMDB along with iPhone SQLite.  Now, if I needed to do anything with the data beyond reading it, Core Data can make all this much easier, and I’d recommend using it.

Conclusion: Core Data just makes so many things so much easier that I would recommend using it unless you already have existing code, or are doing only the most basic database usage.

转载于:https://www.cnblogs.com/guligei/p/3478799.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值