Chapter 20


A fairly common operation when writing software is to take a collection of objects and evaluate them against some kind of known truth. You hang on to objects that conform to the truth and throw out objects that don’t, leaving you with a pile of interesting objects to play with.

You see this all the time with software you use, like iPhoto. If you tell iPhoto to show you only pictures with a rating of three stars or better, the truth you’ve specified is “photo must have a rating of three stars or better.” All of your photos are run through this filter. Those that have a rating of three or more stars pass through it, and the rest don’t. iPhoto then shows you all your good pictures.

Similarly, iTunes has its search box. The ...

Get Learn Objective-C on the Mac: For OS X and iOS, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.