SDWebImageDownloaderOperation

The download operation class for SDWebImageDownloader.

  • The request used by the operation’s task.

    Declaration

    Objective-C

    @property (readonly, strong, nonatomic, nullable) NSURLRequest *request;

    Swift

    var request: URLRequest? { get }
  • The response returned by the operation’s task.

    Declaration

    Objective-C

    @property (readonly, strong, nonatomic, nullable) NSURLResponse *response;

    Swift

    var response: URLResponse? { get }
  • The operation’s task

    Declaration

    Objective-C

    @property (readonly, strong, nonatomic, nullable) NSURLSessionTask *dataTask;

    Swift

    var dataTask: URLSessionTask? { get }
  • The collected metrics from -URLSession:task:didFinishCollectingMetrics:. This can be used to collect the network metrics like download duration, DNS lookup duration, SSL handshake duration, etc. See Apple’s documentation: https://developer.apple.com/documentation/foundation/urlsessiontaskmetrics

    Declaration

    Objective-C

    @property (readonly, strong, nonatomic, nullable) NSURLSessionTaskMetrics *metrics;

    Swift

    var metrics: URLSessionTaskMetrics? { get }
  • The credential used for authentication challenges in -URLSession:task:didReceiveChallenge:completionHandler:.

    This will be overridden by any shared credentials that exist for the username or password of the request URL, if present.

    Declaration

    Objective-C

    @property (strong, nonatomic, nullable) NSURLCredential *credential;

    Swift

    var credential: URLCredential? { get set }
  • The minimum interval about progress percent during network downloading. Which means the next progress callback and current progress callback’s progress percent difference should be larger or equal to this value. However, the final finish download progress callback does not get effected. The value should be 0.0-1.0.

    Note

    If you’re using progressive decoding feature, this will also effect the image refresh rate.

    Note

    This value may enhance the performance if you don’t want progress callback too frequently. Defaults to 0, which means each time we receive the new data from URLSession, we callback the progressBlock immediately.

    Declaration

    Objective-C

    @property (nonatomic) double minimumProgressInterval;

    Swift

    var minimumProgressInterval: Double { get set }
  • The options for the receiver.

    Declaration

    Objective-C

    @property (readonly, nonatomic) SDWebImageDownloaderOptions options;

    Swift

    var options: SDWebImageDownloaderOptions { get }
  • The context for the receiver.

    Declaration

    Objective-C

    @property (readonly, copy, nonatomic, nullable) SDWebImageContext *context;

    Swift

    var context: [SDWebImageContextOption : Any]? { get }
  • Initializes a SDWebImageDownloaderOperation object

    See

    SDWebImageDownloaderOperation

    Declaration

    Objective-C

    - (nonnull instancetype)initWithRequest:(nullable NSURLRequest *)request
                                  inSession:(nullable NSURLSession *)session
                                    options:(SDWebImageDownloaderOptions)options;

    Swift

    convenience init(request: URLRequest?, in session: URLSession?, options: SDWebImageDownloaderOptions = [])

    Parameters

    request

    the URL request

    session

    the URL session in which this operation will run

    options

    downloader options

    Return Value

    the initialized instance

  • Initializes a SDWebImageDownloaderOperation object

    See

    SDWebImageDownloaderOperation

    Declaration

    Objective-C

    - (nonnull instancetype)initWithRequest:(nullable NSURLRequest *)request
                                  inSession:(nullable NSURLSession *)session
                                    options:(SDWebImageDownloaderOptions)options
                                    context:(nullable SDWebImageContext *)context;

    Swift

    init(request: URLRequest?, in session: URLSession?, options: SDWebImageDownloaderOptions = [], context: [SDWebImageContextOption : Any]?)

    Parameters

    request

    the URL request

    session

    the URL session in which this operation will run

    options

    downloader options

    context

    A context contains different options to perform specify changes or processes, see SDWebImageContextOption. This hold the extra objects which options enum can not hold.

    Return Value

    the initialized instance

  • Adds handlers for progress and completion. Returns a tokent that can be passed to -cancel: to cancel this set of callbacks.

    Declaration

    Objective-C

    - (nullable id)addHandlersForProgress:
                       (nullable SDWebImageDownloaderProgressBlock)progressBlock
                                completed:
                                    (nullable SDWebImageDownloaderCompletedBlock)
                                        completedBlock;

    Swift

    func addHandlers(forProgress progressBlock: SDWebImageDownloaderProgressBlock?, completed completedBlock: SDWebImageDownloaderCompletedBlock? = nil) -> Any?

    Parameters

    progressBlock

    the block executed when a new chunk of data arrives. - note: the progress block is executed on a background queue

    completedBlock

    the block executed when the download is done. - note: the completed block is executed on the main queue for success. If errors are found, there is a chance the block will be executed on a background queue

    Return Value

    the token to use to cancel this set of handlers

  • Cancels a set of callbacks. Once all callbacks are canceled, the operation is cancelled.

    Declaration

    Objective-C

    - (BOOL)cancel:(nullable id)token;

    Swift

    func cancel(_ token: Any?) -> Bool

    Parameters

    token

    the token representing a set of callbacks to cancel

    Return Value

    YES if the operation was stopped because this was the last token to be canceled. NO otherwise.