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​)​ ​ ​ ​ ​.​.​.​ ...

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.