Instance Method

urlSession(_:didBecomeInvalidWithError:)

Tells the URL session that the session has been invalidated.

Declaration

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

Parameters

session

The session object that was invalidated.

error

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

Discussion

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.