Recipe: Downloads with Feedback

The block-based factory methods provided by NSURLSession create tasks with a convenient completion handler. When a task is completed, you can process your data and move on. While these methods are simple to use, sometimes you may need more interaction during your download or upload. NSURLSessionDelegate and its family of subprotocols provide more access and configurability to your tasks. The subprotocols include support for the parent NSURLSession-related delegate methods as well as callbacks specific to a general task, data task, or download task.

These delegates provide corresponding data about the progress or state of your session and tasks. Your NSURLSession object maintains a single, common delegate object ...

Get The Core iOS Developer’s Cookbook, Fifth Edition 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.