O'Reilly logo

Advanced Mac OS X Programming: The Big Nerd Ranch Guide by Mark Dalrymple

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

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

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

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