Protocol

NSURLSessionDataDelegate

The NSURLSessionDataDelegate protocol defines the methods that a delegate of an NSURLSession object can implement to handle task-level events specific to data tasks and upload tasks.

Overview

Your session delegate should also implement the methods in the NSURLSessionTaskDelegate protocol to handle task-level events that are common to all task types, and methods in the NSURLSessionDelegate protocol to handle session-level events.

Topics

Delegate Methods

URLSession:dataTask:didReceiveResponse:completionHandler:

Tells the delegate that the data task received the initial reply (headers) from the server.

URLSession:dataTask:didBecomeDownloadTask:

Tells the delegate that the data task was changed to a download task.

URLSession:dataTask:didBecomeStreamTask:

Tells the delegate that the data task was changed to a streamtask.

URLSession:dataTask:didReceiveData:

Tells the delegate that the data task has received some of the expected data.

URLSession:dataTask:willCacheResponse:completionHandler:

Asks the delegate whether the data (or upload) task should store the response in the cache.

Constants

NSURLSessionResponseDisposition

Constants indicating how a data or upload session should proceed after receiving the initial headers.

Relationships

See Also

Adding Data Tasks to a Session

dataTaskWithURL:

Creates a task that retrieves the contents of the specified URL.

dataTaskWithURL:completionHandler:

Creates a task that retrieves the contents of the specified URL, then calls a handler upon completion.

dataTaskWithRequest:

Creates a task that retrieves the contents of a URL based on the specified URL request object.

dataTaskWithRequest:completionHandler:

Creates a task that retrieves the contents of a URL based on the specified URL request object, and calls a handler upon completion.

NSURLSessionDataTask

A URL session task that returns downloaded data directly to the app in memory.