ImageSnarfer
The next exercise is ImageSnarfer, which loads a batch of images from a website, controlled by a text file containing URLs, and displays them in a view. The NSOperation subclass will be a complex-lifetime operation.
Figure 21.4 ImageSnarfer screen
The SnarfOperation class uses NSURLConnection to download an image asynchronously. This exercise uses Objective-C 2.0 features and KVO notifications.
There are two other classes involved: ImageCanvas, which draws an array of images (fed by SnarfOperations), and AppController, which reads a text file of URLs and creates operations. All of these classes are shown in Figure 21.5.
Figure 21.5 ImageSnarfer ...
Get Advanced Mac OS X Programming: 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.