Beginning Networking with URLSession, Episode 13: Challenge: Download Images | Kodeco, the new raywenderlich.com

Leverage the concepts learned in the previous lecture, but apply them towards downloading images corresponding to album artwork.


This is a companion discussion topic for the original entry at https://www.kodeco.com/28450876-beginning-networking-with-urlsession/lessons/13

Is it ok to use session.data(from: url) instead of session.download(from: url) and omit the check at the end? Or is there an advantage to safe the image first?

There should be no major difference between the two implementations.

You could call session.data(from: url), check the response first, and then attempt to save the image to temporary (or permanent) storage.

Alternatively, the video. uses session.download(from: url) which conveniently saves it for you to temporary storage along with providing the response to check how things went.

Both implementations are perfectly fine and should work the same, so whichever you prefer is ok :slight_smile:

1 Like