Tasks

Each unit of work in a session is defined by an NSURLSessionTask object. Tasks are a close corollary to the original NSURLConnection class, each representing a single network request. A task provides the current state of a request. Once active, you can use a task to cancel, suspend, or resume activity. Much of the connection state that required the implementation of a delegate to access in NSURLConnection are now available as properties on NSURLSessionTask.

NSURLSessionTask is an abstract class with three concrete classes provided for general data transfers, download, and upload functions, as shown in Figure 13-1 (left): NSURLDataTask, NSURLDownloadTask, and NSURLUploadTask. All these tasks support a convenient block-based handler as well ...

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.