核心数据与NSUserDefaults-notes应用 [英] Difference between core data & NSUserDefaults-notes app

查看:116
本文介绍了核心数据与NSUserDefaults-notes应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

创建一个预算应用程序(不用于发布,只是一些快速而肮脏的事情),我在启动主从模板时注意到苹果使用Core Data和NSFetch结果填充表格(在iPad上考虑Notes)。

Creating a budget app (not for release, just something quick & dirty) and I noticed upon starting the Master-Detail template that Apple uses Core Data and NSFetch results to populate the tables (think Notes on an iPad).

我缺乏经验和不专业的编程本能,不会三思而后行地抓住NSMutableArray,将表单元格的名称填充到索引中,然后将其保存为NSUserDefault然后在重新加载应用程序后,使用NSMutableArray中的相同索引填充当前索引中的每个单元格,以便将内容返回到用户离开它的位置。只是想知道,与使用核心数据相比,这效率如何?

My inexperienced and unprofessional programming instincts wouldn't think twice about grabbing an NSMutableArray, taking the names of the table cells and cramming them into an index, saving that as an NSUserDefault and then upon reloading the app, populate each cell at it's current index with the same index in the NSMutableArray so the contents is back where the user left it. Just wondering, how inefficient is this compared to using Core Data?

另一方面,在两个都包含动态数据的不同表之间进行通信的简便方法是吗?

On a side note, any easy way of communicating between two different tables that both hold dynamic data?

推荐答案

多达数百条记录,不必担心。的确确实是快速又肮脏。

Up to a few hundred records, don't worry about it. It would be indeed wonderfully "quick and dirty".

不过,Core Data的学习曲线并不像您期望的那样陡峭。一旦掌握了它-并且简单的应用程序是探索该API的绝佳方法-您将发现您想使用它进行所有操作。即使是大型项目也似乎很容易。

Still, the learning curve for Core Data is not as steep as you might expect. Once you get the hang of it - and your simple app is great way to explore that API - you will find that you want to do everything with it. Even large projects will seem easy.

您的选择。

这篇关于核心数据与NSUserDefaults-notes应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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