Protocol: NSURLConnectionDownloadDelegate

Overview

The NSURLConnectionDownloadDelegate protocol enables the delegate adopting the protocol to receive progress information about the download of a URL asset and, when downloading concludes, to get a file URL locating the downloaded file in the local file system.Sent to the delegate to deliver progress information for a download of a URL asset to a destination file.Sent to the delegate when the URL connection has successfully downloaded the URL asset to a destination file.Sent to the delegate when an URL connection resumes downloading a URL asset that was earlier suspended.

Instance Method Summary (collapse)

Instance Method Details

- (Object) connection(connection, didWriteData:bytesWritten, totalBytesWritten:totalBytesWritten, expectedTotalBytes:expectedTotalBytes)

Sent to the delegate to deliver progress information for a download of a URL asset to a destination file. This method is invoked repeatedly during the download of a URL asset to the destination file. The delegate typically uses the values of the three “bytes” parameters to update a progress indicator in the application’s user interface.

Parameters:

  • connection (NSURLConnection)

    The URL connection object downloading the asset.

  • bytesWritten (Integer)

    The number of bytes written since the last call of this method.

  • totalBytesWritten (Integer)

    The total number of bytes of the downloading asset that have been written to the file.

  • expectedTotalBytes (Integer)

    The total number of bytes of the URL asset once it is completely downloaded and written to a file. This parameter can be zero if the total number of bytes is not known.

Returns:

- (Object) connectionDidFinishDownloading(connection, destinationURL:destinationURL)

Sent to the delegate when the URL connection has successfully downloaded the URL asset to a destination file. This method will be called once after a successful download. The file downloaded to destinationURL is guaranteed to exist there only for the duration of this method implementation; the delegate should copy or move the file to a more persistent and appropriate location.

Parameters:

  • connection (NSURLConnection)

    The URL connection object that downloaded the asset.

  • destinationURL (NSURL)

    A file URL specifying a destination in the file system. For iOS applications, this is a location in the application sandbox.

Returns:

- (Object) connectionDidResumeDownloading(connection, totalBytesWritten:totalBytesWritten, expectedTotalBytes:expectedTotalBytes)

Sent to the delegate when an URL connection resumes downloading a URL asset that was earlier suspended. This method is invoked once a suspended download of a URL asset resumes downloading. In response, the delegate can display a progress indicator, setting the initial value of the indicator to where it was when downloading was suspended. After the URL-connection object sends this message, it sends one or more connection:didWriteData:totalBytesWritten:expectedTotalBytes: to the delegate until the download concludes.

Parameters:

  • connection (NSURLConnection)

    The URL connection object downloading the asset.

  • totalBytesWritten (Integer)

    The total number of bytes of the downloading asset that have been written to the destination file.

  • expectedTotalBytes (Integer)

    The total number of bytes of the URL asset once it is completely downloaded and written to a file.

Returns: