Search code examples
cocoacocoa-touchcore-datacocoa-bindingsnsarraycontroller

What is the Cocoa Touch equivalent to NSArrayController?


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?


Solution

  • 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.