核心数据模型非存储模型和主题演讲?
我在这个主题上有点挣扎,因为我来自 PHP 世界,那里没有像“核心数据”这样的东西(据我所知)。
直到今天,当我需要一个数据模型来保存来自服务器的数据时,假设我从 API 获得了一些用户,我将创建一个名为“MyAppUser”的 NSObject 类,并且在 .h 文件上将具有该数据的属性并在 .m 中综合它,然后使用该类将我的服务器数据排列在漂亮整洁的对象中。
我读了一些关于 Core Data 的内容,它似乎主要用于将数据实际存储在某种数据库中,这不是我想要的。我想要的实际上只是组织对象,并将服务器中的数据返回给我。我可以用核心数据来做到这一点吗?只是拥有对象但没有实际管理和存储它们?
谢谢你,如果我的问题有点“分散”,抱歉:)
谢伊。
i'm struggling a bit with this subject since I come from the world of PHP where you don't have anything like "Core Data" (as far as i know).
Until today, when i needed a data model for saving data from the server , lets say i got some users from an API, i would create an NSObject class called "MyAppUser" , and on the .h file would have the properties for that data and synthesize it in the .m , and then just use that class for arranging my server-data in nice neat objects.
I read a bit about Core Data , and it seems its mainly for actually storing the data in some sort of database, which isn't what i want. What i want is actually just have organized objects with data from my server returned to me. Could i do this with Core Data? just have objects but without actually managing them and storing them ?
Thank you and sorry if my question is a bit "scattered" :)
Shai.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的解释是正确的 - 核心数据是一个持久性框架。它旨在帮助您在会话之间存储和检索数据。对于瞬态数据来说,这是不值得的开销(IMO)。使用自定义对象进行存储,甚至只是一个
NSDictionary
。Your interpretation is correct - core data is a persistence framework. It is designed to help you store and retrieve data between sessions. It's not worth the overhead (IMO) for transient data. Use a custom object for storage, or even just an
NSDictionary
.