Instance Method

urlSession(_:dataTask:didBecome:)

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

Declaration

optional func urlSession(_ session: URLSession, dataTask: URLSessionDataTask, didBecome downloadTask: URLSessionDownloadTask)

Parameters

session

The session containing the task that was replaced by a download task.

dataTask

The data task that was replaced by a download task.

downloadTask

The new download task that replaced the data task.

Discussion

When your urlSession(_:dataTask:didReceive:completionHandler:) delegate method uses the URLSession.ResponseDisposition.becomeDownload disposition to convert the request to use a download, the session calls this delegate method to provide you with the new download task. After this call, the session delegate receives no further delegate method calls related to the original data task.

See Also

Handling Task Life Cycle Changes

enum URLSession.ResponseDisposition

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

func urlSession(URLSession, dataTask: URLSessionDataTask, didBecome: URLSessionStreamTask)

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