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 the delegate’s URLSession:dataTask:didReceiveResponse:completionHandler: method decides to change the disposition from a data request to 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

Delegate Methods

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

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

func urlSession(URLSession, dataTask: URLSessionDataTask, didReceive: Data)

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