iOS核心数据:对核心数据和数据库感到困惑 [英] iOS Core Data: Confused about Core Data and database

查看:71
本文介绍了iOS核心数据:对核心数据和数据库感到困惑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对核心数据实际上是什么感到困惑。或者我想我的问题是,在处理数据库时,您会使用Core Data吗?就像我想从数据库访问值一样,我是否会使用Core Data访问这些值?我将如何解决这个问题?

I am really confused on what the Core Data actually is. Or I guess my question is, when dealing with a database, would you use Core Data? Like if I wanted access values from a database would I be using Core Data to access those values? How would I approach this problem?

非常感谢您的帮助。

推荐答案

核心数据是执行对象持久性工作的框架。换句话说,您可以使用该代码来将一组对象保存到磁盘中,并在以后再次加载它们。要做很多工作,以允许您存储大量数据并一次仅加载所需的对象,并在内存不足时卸载那些对象。

Core Data is an framework that does the work of "object persistence". In other words, it's code you can use that takes care of saving a collection of objects to disk and loading them again later. It does a lot of work to allow you to store lots of data and load only the objects you need at a time, and unload ones when memory is tight.

核心数据可以使用数据库来完成此任务,但这是业务,而不是您的。使用Core Data时,它是一个黑框。您告诉它保存数据然后走开。

Core Data can use a database to accomplish this, but that's it's business, not yours. When you use Core Data, it is a black box. You tell it to save the data and then step out of the way.

如果要与现有数据库(例如Web服务器上的MySQL数据库)进行交互,那是完全不同的事情。您可能会使用Core Data在设备上存储对象的本地副本,但是在那种情况下,Core Data不会在意这些对象是来自其他数据库的副本。没关系。

If you want to interact with an existing database, such as a MySQL database on a web server, that's a completely different matter. You might use Core Data to store local copies of objects on your device, but in that case Core Data won't care that the objects are copies from some other database. It doesn't care.

这篇关于iOS核心数据:对核心数据和数据库感到困惑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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