Contents

download(resumeFrom:delegate:)

Resumes a previously-paused download and delivers the URL of the saved file asynchronously.

Declaration

func download(resumeFrom resumeData: Data, delegate: (any URLSessionTaskDelegate)? = nil) async throws -> (URL, URLResponse)

Parameters

  • resumeData:

    A data object that provides the data necessary to resume a download.

  • delegate:

    A delegate that receives life cycle and authentication challenge callbacks as the transfer progresses.

Return Value

An asynchronously-delivered tuple that contains the location of the downloaded file as a URL, and a URLResponse.

Discussion

Your app can obtain a resumeData object in two ways:

  • If your app cancels an existing transfer by calling cancel(byProducingResumeData:), the session object passes a resumeData object to the completion handler that you provided in that call.

  • If a transfer fails, the session object provides an NSError object either to its delegate or to the task’s completion handler. In that object, the NSURLSessionDownloadTaskResumeData key in the userInfo dictionary contains a resumeData object.

See Also

Performing asynchronous transfers