使用 NSMutableArray 代替 NSFetchedResultsController
我最近了解到 NSFetchedResultsController 是一个极其有缺陷的类,它在我相当大的 Core Data 应用程序中让我头疼了一段时间。
使用 NSMutableArray
代替 NSFetchedResultsController
来提供表视图是否合适?我所说的是,临时创建一个获取结果控制器以从我的托管对象上下文中获取对象,并使用获取结果控制器中的 fetchedObjects
创建一个新的 NSMutableArray
,然后用它来填充我的表格视图。
直接通过 NSMutableArray
使用 NSFetchedResultsController
向我的表视图提供数据有什么好处吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不必使用获取结果控制器。这是一门新的便利课程,你总是可以做旧学校的事情。
我认为因为您想使用可变数组,所以您打算使用添加和删除对象。这不是问题,除非你必须手动完成所有事情。如果其他内容修改了数据,您必须注册通知以监视更改并根据需要重新获取。
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.