Instance Method


Tells the URL session that the session has been invalidated.


optional func urlSession(_ session: URLSession, didBecomeInvalidWithError error: Error?)



The session object that was invalidated.


The error that caused invalidation, or nil if the invalidation was explicit.


If you invalidate a session by calling its finishTasksAndInvalidate() method, the session waits until after the final task in the session finishes or fails before calling this delegate method. If you call the invalidateAndCancel() method, the session calls this delegate method immediately.

See Also

Delegate Methods

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.