SDWebImageManagerDelegate

@protocol SDWebImageManagerDelegate <NSObject>

The manager delegate protocol.

  • Controls which image should be downloaded when the image is not found in the cache.

    Declaration

    Objective-C

    - (BOOL)imageManager:(nonnull SDWebImageManager *)imageManager
        shouldDownloadImageForURL:(nonnull NSURL *)imageURL;

    Swift

    optional func imageManager(_ imageManager: SDWebImageManager, shouldDownloadImageFor imageURL: URL) -> Bool

    Parameters

    imageManager

    The current SDWebImageManager

    imageURL

    The url of the image to be downloaded

    Return Value

    Return NO to prevent the downloading of the image on cache misses. If not implemented, YES is implied.

    • Controls the complicated logic to mark as failed URLs when download error occur.
    • If the delegate implement this method, we will not use the built-in way to mark URL as failed based on error code;

    Declaration

    Objective-C

    - (BOOL)imageManager:(nonnull SDWebImageManager *)imageManager
        shouldBlockFailedURL:(nonnull NSURL *)imageURL
                   withError:(nonnull NSError *)error;

    Swift

    optional func imageManager(_ imageManager: SDWebImageManager, shouldBlockFailedURL imageURL: URL, withError error: Error) -> Bool

    Parameters

    imageManager

    The current SDWebImageManager

    imageURL

    The url of the image

    error

    The download error for the url

    Return Value

    Whether to block this url or not. Return YES to mark this URL as failed.