DownloadTask
public final class DownloadTask : Cancellable
extension DownloadTask: CustomStringConvertible
A wrapper around DownloadOperation
. Downloads a file to disk.
-
true
ifcancel()
has been invoked on this task,false
otherwise.Declaration
Swift
public var isCancelled: Bool { get }
-
Initializes a new download task.
Declaration
Swift
public init(operation: DownloadOperation)
Parameters
operation
An operation in a suspended state that would execute the download.
-
Adds a progress block to this instance to be called continuously as data is being downloaded.
Declaration
Swift
@discardableResult public func addProgressBlock(_ block: @escaping (Int64, Int64) -> Void) -> DownloadTask
Parameters
block
A block called on the main thread with the number of downloaded bytes and the total number of bytes to download as first and second arguments, respectively. Called each time the number of downloaded bytes changes.
Return Value
This task.
-
Adds a completion block to this instance to be called when the task completes either successfully or with a failure.
Declaration
Swift
@discardableResult public func addCompletionBlock(_ block: @escaping (Download.Response) -> Void) -> DownloadTask
Parameters
block
A block called on the main thread with the result of the task.
Return Value
This task.
-
Starts the task if it is not already running.
Declaration
Swift
@discardableResult public func start() -> DownloadTask
Return Value
This task.
-
Interrupts and invalidates this task. An invalidated task cannot run again.
Declaration
Swift
public func cancel()
-
Declaration
Swift
public var description: String { get }