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: Filtering

As discussed earlier, NSArrayController arranges its objects by filtering and sorting. These two lenses correspond to properties on NSArrayController: filterPredicate, an NSPredicate, and sortDescriptors, an array of NSSortDescriptor objects.

NSPredicate is a logical operator that can be evaluated against an object. Predicates are typically instantiated using a format string. This predicate evaluates to true when raise is above 5%:

i​f​ ​l​e​t​ ​r​a​i​s​e​P​r​e​d​i​c​a​t​e​ ​=​ ​N​S​P​r​e​d​i​c​a​t​e​(​f​o​r​m​a​t​:​ ​"​r​a​i​s​e​ ​>​ ​0​.​0​5​"​)​ ​{​ ​ ​ ​ ​l​e​t​ ​m​a​t​c​h​e​d​:​ ​B​o​o​l​ ​=​ ​r​a​i​s​e​P​r​e​d​i​c​a​t​e​.​e​v​a​l​u​a​t​e​W​i​t​h​O​b​j​e​c​t​(​e​m​p​l​o​y​e​e​)​ ​ ​ ​ ​.​.​.​ ...

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