O'Reilly logo

iOS Programming: The Big Nerd Ranch Guide, 6th Edition by Aaron Hillegass, Christian Keur

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

Downloading the Image Data

Now all that is left is downloading the image data for the photos that come back in the request. This task is not very difficult, but it requires some thought. Images are large files, and downloading them could eat up your users’ cellular data allowance. As a considerate iOS developer, you want to make sure your app’s data usage is only what it needs to be.

Consider your options. You could download the image data in viewDidLoad() when the fetchInterestingPhotos(completion:) method calls its completion closure. At that point, you already assign the incoming photos to the photos property, so you could iterate over all of those photos and download their image data then.

Although this would work, it would ...

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