English 中文(简体)
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?

最佳回答

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.

问题回答

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.

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





相关问题
How do you create UIBarButtonItems with a radio interface?

I have a UIToolbar that needs three buttons in a radio style, meaning that of the three, only one button can be pushed at a time. The documentation makes reference to the possibility of setting up ...

iPhone settings bundle

I want to allow the user to enter a valid date using the iPhone’s settings application. I have experimented with many of the PreferenceSpecifiers data node types including date. I have two issues: ...

Circular #import/@class problem in ObjectiveC

I m going to use an example to properly illustrate my confusion. I can t quite wrap my head around this. In Cocoa touch, we have UIViewController and its subclass, UINavigationController. Now, UIVC ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Cocoa-Touch: issue looping MPMoviePlayerController

I have an app which has to load some data at startup, so I want to display a splash-screen animation. I m using the MPMoviePlayerController to play a m4v file. The movie has it s background set to [...

Iphone sequential animation with setAnimationDelay

I m trying to chain animation events. The application I m coding for work has a multiple choice quiz. First you pick your multiple choice answer. The quiz view fades away. Then a label ("correct" or "...

热门标签