O'Reilly logo

Cocoa Programming for OS X: The Big Nerd Ranch Guide by Aaron Hillegass, Adam Preble, Nate Chandler

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

For the More Curious: Sorting Without NSArrayController

In Chapter 7, you populated a table view by implementing the data source methods. You might have wondered at that time how you could implement this sorting behavior in SpeakLine.

Recall that clicking on the table column headers updates an array of NSSortDescriptor objects, which the array controller then applies to reorder its content. You can sort any array of NSObject-based objects yourself using the following method on NSArray:

f​u​n​c​ ​s​o​r​t​e​d​A​r​r​a​y​U​s​i​n​g​D​e​s​c​r​i​p​t​o​r​s​(​s​o​r​t​D​e​s​c​r​i​p​t​o​r​s​:​ ​[​A​n​y​O​b​j​e​c​t​]​)​ ​-​>​ ​[​A​n​y​O​b​j​e​c​t​]​

When is the appropriate time to sort? When the user clicks on the header of a column, an ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required