NSURLDownloadDelegate
A protocol that URL download delegates implement to interact with a URL download request.
Declaration
protocol NSURLDownloadDelegate : NSObjectProtocolOverview
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.
A downloadDidBegin(_:) message will be sent to the delegate immediately upon starting the download.
Zero or more download(_:willSend:redirectResponse:) messages will be sent to the delegate before any further messages are sent if it is determined that the download must redirect to a new location. The delegate can allow the redirect, modify the destination or deny the redirect.
Zero or more download(_:didReceive:) messages will be sent to the delegate if it is necessary to authenticate in order to download the request and NSURLDownload does not already have authenticated credentials.
Zero or more download(_:didCancel:) messages will be sent to the delegate if NSURLDownload cancels the authentication challenge due to encountering a protocol implementation error.
Zero or more download(_:didReceive:) messages will be sent to the delegate before receiving a download(_:didReceiveDataOfLength:) message. The only case where download(_:didReceive:) is not sent to a delegate is when the protocol implementation encounters an error before a response could be created.
Zero or more download(_:didReceiveDataOfLength:) messages will be sent before downloadDidFinish(_:) or download(_:didFailWithError:) is sent to the delegate.
Zero or one download(_:decideDestinationWithSuggestedFilename:) will be sent to the delegate when sufficient information has been received to determine the suggested filename for the downloaded file. The delegate will not receive this message if setDestination(_:allowOverwrite:) has already been sent to the NSURLDownload instance.
A download(_:didCreateDestination:) message will be sent to the delegate when the NSURLDownload instance creates the file on disk.
If NSURLDownload determines that the downloaded file is in a format that it is able to decode (MacBinary, Binhex or gzip), the delegate will receive a download(_:shouldDecodeSourceDataOfMIMEType:). The delegate should return true to decode the data, false otherwise.
Unless an NSURLDownload instance receives a cancel() message, the delegate will receive one and only one downloadDidFinish(_:) or download(_:didFailWithError:) message, but never both. In addition, once either of these messages are sent, the delegate will receive no further messages for the given NSURLDownload.
Topics
Download Authentication
download(_:canAuthenticateAgainstProtectionSpace:)download(_:didCancel:)download(_:didReceive:)downloadShouldUseCredentialStorage(_:)
Download Data and Responses
download(_:decideDestinationWithSuggestedFilename:)downloadDidBegin(_:)download(_:didCreateDestination:)download(_:didReceive:)download(_:didReceiveDataOfLength:)download(_:shouldDecodeSourceDataOfMIMEType:)download(_:willResumeWith:fromByte:)download(_:willSend:redirectResponse:)