Protocol

URLSessionDelegate

The NSURLSessionDelegate protocol describes the methods that URLSession objects call on their delegates to handle session-level events. In addition to the methods defined in this protocol, most delegates should also implement some or all of the methods in the URLSessionTaskDelegate, URLSessionDataDelegate, and URLSessionDownloadDelegate protocols to handle task-level events.

Overview

Topics

Delegate Methods

func urlSession(URLSession, didBecomeInvalidWithError: Error?)

Tells the URL session that the session has been invalidated.

func urlSession(URLSession, didReceive: URLAuthenticationChallenge, completionHandler: (URLSession.AuthChallengeDisposition, URLCredential?) -> Void)

Requests credentials from the delegate in response to a session-level authentication request from the remote server.

func urlSessionDidFinishEvents(forBackgroundURLSession: URLSession)

Tells the delegate that all messages enqueued for a session have been delivered.

Constants

enum URLSession.AuthChallengeDisposition

Constants passed by session or task delegates to the provided continuation block in response to an authentication challenge.

Relationships

Inherits From

See Also

Configuring a Session

var configuration: URLSessionConfiguration

A copy of the configuration object for this session.

var delegate: URLSessionDelegate?

The delegate assigned when this object was created.

protocol URLSessionTaskDelegate

The NSURLSessionTaskDelegate protocol defines the task-specific delegate methods that you should implement when working with any type of URLSession task.

var delegateQueue: OperationQueue

The operation queue provided when this object was created.

var sessionDescription: String?

An app-defined descriptive label for the session.