使用NSMutableArray而不是NSFetchedResultsController [英] Using an NSMutableArray instead of an NSFetchedResultsController

查看:58
本文介绍了使用NSMutableArray而不是NSFetchedResultsController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近发现 NSFetchedResultsController 是一个非常有问题的类,并且由于相当庞大的Core Data应用程序,它让我头疼了一段时间。



使用 NSMutableArray 而不是 NSFetchedResultsController ?我要说的是,临时创建一个获取的结果控制器以从托管对象上下文中获取对象,并使用 fetchedObjects创建一个新的 NSMutableArray ,然后使用它来提供我的表格视图。



使用 NSFetchedResultsController有什么好处直接通过 NSMutableArray 来向我的表视图提供数据吗?

解决方案

您不必使用提取的结果控制器。这是一门新的便利课,您总是可以在老学校做一些事情。



我认为这是因为您要使用可变数组,因此打算使用添加和删除对象。这不是问题,除非您必须手动进行所有操作。如果其他修改数据,则必须注册通知以监视更改并根据需要重新获取。


I've recently come to learn that NSFetchedResultsController is an extremely buggy class and its been causing me headaches for a while now with my rather large Core Data app.

Would it be appropriate to use an NSMutableArray to feed the table view instead of an NSFetchedResultsController? What I'm talking about is, temporarily creating a fetched results controller to grab the objects from my managed object context, creating a new NSMutableArray with the fetchedObjects from the fetched results controller, then using that to feed my table view.

Are there any benefits to using NSFetchedResultsController directly over an NSMutableArray to supply data to my table view?

解决方案

You don't have to use a fetched results controller. It is a new convenience class and you can always do things old school.

I presume that because you want to use mutable array that you intend to use add and remove objects. This is not a problem except you have to everything manually. If something else modifies the data, you have to register notifications to monitor the changes and refetch as needed.

这篇关于使用NSMutableArray而不是NSFetchedResultsController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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