还有一个“我应该使用核心数据吗?”问题
我对核心数据知之甚少。阅读:我读过一些教程,有点了解它是如何工作的,但从未尝试在我的任何应用程序中使用它。也就是说,我想知道是否值得在我正在开发的应用程序中使用它。请注意,我并不是在问我是否应该学习核心数据,而是如果值得为我正在制作的这个特定应用程序投入时间学习它,或者我是否应该使用归档来代替,请发布该应用程序,然后才在业余时间学习Core Data。
基本上,我的应用程序从 Web 服务读取项目列表,并且需要保存最后 N 个项目。用户还应该能够为项目添加书签,所以这是我应该存储在某个地方的另一件事。所以,现在我只是归档一个包含 0-N 范围的最新项目的子数组。有效吗?是的。它是否高效且是实现这一目标的最佳方式?这实际上是我要问你的问题。
我的怀疑来自于这样一个事实:每当我看到有人问“核心数据对于我的项目来说是不是太过分了?”无论如何,每个人都建议使用它。
I know little about Core Data. Read: I've read a few tutorials, kinda understood how it works, but never tried to use it in any of my apps. That said, I'd like to know if it's worth the effort to use it in the app I'm developing. Note that I'm not asking if I should learn Core Data, but if it's worthwhile to invest time learning it for this specific app I'm making, or if I should use archiving instead, ship the app, and only then learn Core Data in my spare time.
Basically my app reads a list of items from a web service, and needs to save the last N items. The user should also be able to bookmark items, so that's another thing I should store somewhere. So, right now I'm just archiving a subarray with range 0-N of the latest items. Does it work? Yes. Is it efficient, and the best way to achieve this? That's my question for you actually.
My doubt comes from the fact that whenever I see someone asking 'Is Core Data overkill for my project?' everyone suggests to use it anyway.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您需要保留的数据量可以轻松放入内存而不降低应用程序的性能,那么您应该只归档阵列并交付应用程序。
在处理大型且复杂的数据集时,核心数据具有很多优势。它在维护和升级已发布的应用程序方面提供了很多优势。然而,这些优势不应妨碍交付已完成的应用程序。稍后,您始终可以编写代码将已发布的版本迁移到 Core Data 版本。这是更多的工作,但是嘿,至少你有一个可以使用的已发布的应用程序。
我见过很多小型初创公司/开发人员来来去去,区分成功与不成功的主要因素是成功的实际发布/发布产品。您可以花很长时间来完善应用程序,但关键是知道何时说“它已经足够好了”并将其交到用户手中。
If the amount of data you need to persist can easily fit into memory without degrading the apps performance then you should just archive the array and ship the app.
Core Data gives a lot of advantages when handling large and complex data sets. It gives a lot of advantages in maintaining and upgrading a shipped app. However, those advantages should not get in the way of shipping an otherwise completed app. Later, you can always write code to migrate a shipped version to a Core Data version. It's more work, but hey, at least you've got a shipped app to work on.
I've seen a lot of small startups/developers come and go and the major factor that separates the successful from non-succesful is that the successful actually ship/release product. You can spend forever polishing an app but the key thing is knowing when to say, "It's good enough" and get the thing into the user's hands.
如果它是一个小列表,并且您在 NSDictionary 或 NSArray 集合中拥有数据,请使用 writeToFile:atomically: 代替平面文件 XML Plist 存储。
我仍然认为你最终应该学习核心数据,但是。
If it's a small list and you have the data in NSDictionary or NSArray collections, use
writeToFile:atomically:
instead for flat file XML Plist storage.I still think you should learn Core Data eventually, but.