A protocol that URL download delegates implement to interact with a URL download request.


protocol NSURLDownloadDelegate


The NSURLDownloadDelegate protocol defines methods that allow an object to receive informational callbacks about the asynchronous load of a download’s URL request. Other delegate methods provide facilities that allow the delegate to customize the process of performing an asynchronous URL load.

Note that these delegate methods will be called on the thread that started the asynchronous load operation for the associated NSURLDownload object.


Download Authentication

func download(NSURLDownload, canAuthenticateAgainstProtectionSpace: URLProtectionSpace) -> Bool

Sent to determine whether the delegate is able to respond to a protection space’s form of authentication.

func download(NSURLDownload, didCancel: URLAuthenticationChallenge)

Sent if an authentication challenge is canceled due to the protocol implementation encountering an error.

func download(NSURLDownload, didReceive: URLAuthenticationChallenge)

Sent when the URL download must authenticate a challenge in order to download the request.

func downloadShouldUseCredentialStorage(NSURLDownload) -> Bool

Sent to determine whether the URL loader should consult the credential storage to authenticate the download.

Download Data and Responses

func download(NSURLDownload, decideDestinationWithSuggestedFilename: String)

The delegate receives this message when download has determined a suggested filename for the downloaded file.

func downloadDidBegin(NSURLDownload)

Sent immediately after a download object begins a download.

func download(NSURLDownload, didCreateDestination: String)

Sent when the destination file is created.

func download(NSURLDownload, didReceive: URLResponse)

Sent when a download object has received sufficient load data to construct the NSURLResponse object for the download.

func download(NSURLDownload, didReceiveDataOfLength: Int)

Sent as a download object receives data incrementally.

func download(NSURLDownload, shouldDecodeSourceDataOfMIMEType: String) -> Bool

Sent when a download object determines that the downloaded file is encoded to inquire whether the file should be automatically decoded.

func download(NSURLDownload, willResumeWith: URLResponse, fromByte: Int64)

Sent when a download object has received a response from the server after attempting to resume a download.

func download(NSURLDownload, willSend: URLRequest, redirectResponse: URLResponse?) -> URLRequest?

Sent when the download object determines that it must change URLs in order to continue loading a request.

Download Completion

func download(NSURLDownload, didFailWithError: Error)

Sent if the download fails or if an I/O error occurs when the file is written to disk.

func downloadDidFinish(NSURLDownload)

Sent when a download object has completed downloading successfully and has written its results to disk.


Inherits From

See Also

URL Download

class NSURLDownload

An object that downloads a resource asynchronously and saves the data to a file.