April 2015
Intermediate to advanced
556 pages
17h 47m
English
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%:
if let raisePredicate = NSPredicate(format: "raise > 0.05") {
let matched: Bool = raisePredicate.evaluateWithObject(employee)
...
}
You can also create an array by filtering another. This predicate performs a case-insensitive comparison on the name and requires that ...
Read now
Unlock full access