DownloadOperation

public protocol DownloadOperation : NetworkOperation

A network operation that knows how to execute a download.

  • The result from executing the download. Exists only when state is NetworkOperationState.completed.

    Declaration

    Swift

    var response: Download.Response? { get }
  • The number of bytes currently downloaded.

    Declaration

    Swift

    var numberOfBytesReceived: Int64 { get }
  • The total number of bytes to download.

    Declaration

    Swift

    var totalNumberOfBytesToReceive: Int64 { get }
  • Adds a block to be called on a specific queue when numberOfBytesReceived changes.

    Declaration

    Swift

    @discardableResult
    func addProgressBlock(with queue: DispatchQueue?, _ block: @escaping (Int64, Int64) -> Void) -> Self

    Parameters

    queue

    A queue to call block on. If nil, the queue on which block will be called is undefined.

    block

    A block called with the number of bytes currently uploaded and the total number of bytes to upload as first and second input arguments respectivly. Referenced strongly by the operation.

  • Adds a block to be called on a specific queue when the operation receives its response.

    Declaration

    Swift

    @discardableResult
    func addCompletionBlock(with queue: DispatchQueue?, _ block: @escaping (Download.Response) -> Void) -> Self

    Parameters

    queue

    A queue to call block on. If nil, the queue on which block will be called is undefined.

    block

    Called as soon as the operation receives its response. Referenced strongly by the operation.