What is the Cocoa Touch equivalent to NSArrayController?

时光总嘲笑我的痴心妄想 提交于 2019-12-10 14:10:30

问题


Been starting to work with Core Data a bit, and while I've figured out how to use it in regular Cocoa applications, it seems it works a bit differently in Cocoa Touch. How do you bind entities to objects such as table cells in Cocoa Touch?


回答1:


If you're using CoreData on iPhone OS 3.0 and above, you'll want to look at NSFetchedResultsController. While not really an analog to NSArrayController, it is designed specifically to be used with UITableView and its controller.

It provides a way to load elements from persistence as needed, keeping in mind performance and memory constraints of the device. It's not as clean as simply binding things, but it will probably do everything you need (and more!) with a small amount of code.




回答2:


Unfortunately, bindings are not supported in the iPhone OS. See this page in the Apple developer docs.

I believe this means that you can't use the NSArrayController in the iPhone OS.




回答3:


Jergason is correct: you can not use bindings or the NSArrayController with Core Data on the iPhone.

Instead, check out NSFetchedResultsController which "is intended to efficiently manage the results returned from a Core Data fetch request to provide data for a UITableView object."



来源:https://stackoverflow.com/questions/1811242/what-is-the-cocoa-touch-equivalent-to-nsarraycontroller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!