Downloading files with a progress bar

AFNetworking includes a UIProgressView+AFNetworking category that makes it easy to add a progress bar to either an upload or download session task. In this recipe, we will create the NSURLSessionDownloadTask using AFNetworking and then add a progress bar to show the progress of the download.

Getting ready

You will need to download and add AFNetworking to your project. You will also need to include the UIProgressView+AFNetworking class from the UIKit+AFNetworking directory into your project. The UIKit+AFNetworking files are included when you download AFNetworking.

How to do it…

Let's look at how we would add a progress bar to our projects.

Creating the download task

The download task will simply download a large ...

Get iOS and OS X Network Programming Cookbook 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.