# NSURLDownload class documentation

Software documentation for the NSURLDownload class
Foundation/NSURLDownload.h
Handles download to file.
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.
canResumeDownloadDecodedWithEncodingMIMEType:
MIMEType
Returns a flag saying whether the class can resume a download which was decoded with MIMEType.
cancel
Cancels the download and deletes any downloaded file.
deletesFileUponFailure
Returns a flag saying whether a partially downloaded file should be deleted on failure... `YES` by default.
initWithRequest:
request
delegate:
delegate
Initialises the receiver and start the download process.
initWithResumeData:
resumeData
delegate:
delegate
path:
path
Initialises the receiver with data from a previous partial download and resumes (or restarts) the downloading process.
request
Returns the receiver's request.
resumeData
Returns state data of an incomplete download... this data should be sufficient to resume/restart the download using the -initWithResumeData:delegate:path: method.
Returns `nil` if a resume is probably impossible.
NB. You need to call -setDeletesFileUponFailure: to turn off deletion if you wish to be able to resume an incomplete download.
setDeletesFileUponFailure:
deletesFileUponFailure
Sets a flag to determine if downloaded file is be deleted upon failure. This is `YES` by default and needs to be set to `NO` if you want to be able to attempt to resume a failed download.
setDestination:
path
allowOverwrite:
allowOverwrite
Sets the path to which the file is downloaded.
May be called (once only) after initialisation of the receiver or when the delegate receives a -download:decideDestinationWithSuggestedFilename: message.
Appends a number to the filename if allowOverwrite is `NO` and a file already exists at path.
See -download:didCreateDestination: also.
Software documentation for the NSObject(NSURLDownloadDelegate) category
Foundation/NSURLDownload.h
Description forthcoming.
download:
download
decideDestinationWithSuggestedFilename:
filename
Called when it's time to establish a name for the downloaded file... the delegate may decide a name by inspecting the response.
The delegate should call -setDestination:allowOverwrite: to set the filename to be used.
download:
download
didCancelAuthenticationChallenge:
challenge
Called when authentication of a request is cancelled.
download:
download
didCreateDestination:
path
Called when the download has created the downloaded file.
download:
download
didFailWithError:
error
Called when the download fails.
download:
download
didReceiveAuthenticationChallenge:
challenge
Called when an authentication challenge is received.
The delegate should send -useCredential:forAuthenticationChallenge: or -continueWithoutCredentialForAuthenticationChallenge: or -cancel to the connection sender when done.
download:
download
didReceiveDataOfLength:
length
Called when some data has been received.
download:
download
didReceiveResponse:
response
Called when a response is received.
Multiple responses may be received on the same download (eg with server push) and the delegate should be prepared to treat each separately.
download:
download
shouldDecodeSourceDataOfMIMEType:
encodingType
Called if the download file is encoded... the delegate should return `YES` if the downloaded data is to be decoded, `NO` otherwise.
download:
download
willResumeWithResponse:
response
fromByte:
startingByte
Called when a download is resuming from previously stored data and a response has been received from the server.
The startingBytes is the offset from which the downloaded data will actually commence... and may be zero if the entire download must be redone.
download:
download
willSendRequest:
request
redirectResponse:
redirectResponse
Called if a new request has to be sent due to redirection.
Must return the request argument (or a modified copy of it) to have the process continue.
downloadDidFinish:
download
Called when the download completes after having received all data.
Software documentation for the NSURLDownloadDelegate protocol
Foundation/NSURLDownload.h
NSObject
Description forthcoming.