Introducing NSArrayController

You have already used a table view in SpeakLine. SpeakLine’s use of NSTableView, however, was basic, allowing only simple user interaction. RaiseMan’s table view will be much more dynamic. Rows will be added, edited, removed, and sorted. One way to implement this would be with a table view data source and delegate in the Document class. This is such a common task, however, that Cocoa provides a class for just this purpose: NSArrayController.

NSArrayController, like any controller, serves as the glue between a view and its model, an array of objects. In SpeakLine, the window controller was the table view data source and delegate, supplying data to the view and reacting to selection changes. NSArrayController ...

Get Cocoa Programming for OS X: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.