UIImageView(WebCache)

@interface UIImageView (WebCache)

Integrates SDWebImage async downloading and caching of remote images with UIImageView.

  • Set the imageView image with an url.

    The download is asynchronous and cached.

    Declaration

    Objective-C

    - (void)sd_setImageWithURL:(nullable NSURL *)url;

    Swift

    func __sd_setImage(with url: URL?)

    Parameters

    url

    The url for the image.

  • Set the imageView image with an url and a placeholder.

    The download is asynchronous and cached.

    See

    sd_setImageWithURL:placeholderImage:options:

    Declaration

    Objective-C

    - (void)sd_setImageWithURL:(nullable NSURL *)url
              placeholderImage:(nullable UIImage *)placeholder;

    Swift

    func __sd_setImage(with url: URL?, placeholderImage placeholder: UIImage?)

    Parameters

    url

    The url for the image.

    placeholder

    The image to be set initially, until the image request finishes.

  • Set the imageView image with an url, placeholder and custom options.

    The download is asynchronous and cached.

    Declaration

    Objective-C

    - (void)sd_setImageWithURL:(nullable NSURL *)url
              placeholderImage:(nullable UIImage *)placeholder
                       options:(SDWebImageOptions)options;

    Swift

    func __sd_setImage(with url: URL?, placeholderImage placeholder: UIImage?, options: SDWebImageOptions = [])

    Parameters

    url

    The url for the image.

    placeholder

    The image to be set initially, until the image request finishes.

    options

    The options to use when downloading the image. - see: SDWebImageOptions for the possible values.

  • Set the imageView image with an url, placeholder, custom options and context.

    The download is asynchronous and cached.

    Declaration

    Objective-C

    - (void)sd_setImageWithURL:(nullable NSURL *)url
              placeholderImage:(nullable UIImage *)placeholder
                       options:(SDWebImageOptions)options
                       context:(nullable SDWebImageContext *)context;

    Swift

    func sd_setImage(with url: URL?, placeholderImage placeholder: UIImage?, options: SDWebImageOptions = [], context: [SDWebImageContextOption : Any]?)

    Parameters

    url

    The url for the image.

    placeholder

    The image to be set initially, until the image request finishes.

    options

    The options to use when downloading the image. - see: SDWebImageOptions for the possible values.

    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.

  • Set the imageView image with an url.

    The download is asynchronous and cached.

    Declaration

    Objective-C

    - (void)sd_setImageWithURL:(nullable NSURL *)url
                     completed:(nullable SDExternalCompletionBlock)completedBlock;

    Swift

    func sd_setImage(with url: URL?, completed completedBlock: SDExternalCompletionBlock? = nil)

    Parameters

    url

    The url for the image.

    completedBlock

    A block called when operation has been completed. This block has no return value and takes the requested UIImage as first parameter. In case of error the image parameter is nil and the second parameter may contain an NSError. The third parameter is a Boolean indicating if the image was retrieved from the local cache or from the network. The fourth parameter is the original image url.

  • Set the imageView image with an url, placeholder.

    The download is asynchronous and cached.

    Declaration

    Objective-C

    - (void)sd_setImageWithURL:(nullable NSURL *)url
              placeholderImage:(nullable UIImage *)placeholder
                     completed:(nullable SDExternalCompletionBlock)completedBlock;

    Swift

    func __sd_setImage(with url: URL?, placeholderImage placeholder: UIImage?, completed completedBlock: SDExternalCompletionBlock? = nil)

    Parameters

    url

    The url for the image.

    placeholder

    The image to be set initially, until the image request finishes.

    completedBlock

    A block called when operation has been completed. This block has no return value and takes the requested UIImage as first parameter. In case of error the image parameter is nil and the second parameter may contain an NSError. The third parameter is a Boolean indicating if the image was retrieved from the local cache or from the network. The fourth parameter is the original image url.

  • Set the imageView image with an url, placeholder and custom options.

    The download is asynchronous and cached.

    Declaration

    Objective-C

    - (void)sd_setImageWithURL:(nullable NSURL *)url
              placeholderImage:(nullable UIImage *)placeholder
                       options:(SDWebImageOptions)options
                     completed:(nullable SDExternalCompletionBlock)completedBlock;

    Swift

    func sd_setImage(with url: URL?, placeholderImage placeholder: UIImage?, options: SDWebImageOptions = [], completed completedBlock: SDExternalCompletionBlock? = nil)

    Parameters

    url

    The url for the image.

    placeholder

    The image to be set initially, until the image request finishes.

    options

    The options to use when downloading the image. - see: SDWebImageOptions for the possible values.

    completedBlock

    A block called when operation has been completed. This block has no return value and takes the requested UIImage as first parameter. In case of error the image parameter is nil and the second parameter may contain an NSError. The third parameter is a Boolean indicating if the image was retrieved from the local cache or from the network. The fourth parameter is the original image url.

  • Set the imageView image with an url, placeholder and custom options.

    The download is asynchronous and cached.

    Declaration

    Objective-C

    - (void)sd_setImageWithURL:(nullable NSURL *)url
              placeholderImage:(nullable UIImage *)placeholder
                       options:(SDWebImageOptions)options
                      progress:(nullable SDImageLoaderProgressBlock)progressBlock
                     completed:(nullable SDExternalCompletionBlock)completedBlock;

    Swift

    func sd_setImage(with url: URL?, placeholderImage placeholder: UIImage?, options: SDWebImageOptions = [], progress progressBlock: SDImageLoaderProgressBlock?, completed completedBlock: SDExternalCompletionBlock? = nil)

    Parameters

    url

    The url for the image.

    placeholder

    The image to be set initially, until the image request finishes.

    options

    The options to use when downloading the image. - see: SDWebImageOptions for the possible values.

    progressBlock

    A block called while image is downloading - note: the progress block is executed on a background queue

    completedBlock

    A block called when operation has been completed. This block has no return value and takes the requested UIImage as first parameter. In case of error the image parameter is nil and the second parameter may contain an NSError. The third parameter is a Boolean indicating if the image was retrieved from the local cache or from the network. The fourth parameter is the original image url.

  • Set the imageView image with an url, placeholder, custom options and context.

    The download is asynchronous and cached.

    Declaration

    Objective-C

    - (void)sd_setImageWithURL:(nullable NSURL *)url
              placeholderImage:(nullable UIImage *)placeholder
                       options:(SDWebImageOptions)options
                       context:(nullable SDWebImageContext *)context
                      progress:(nullable SDImageLoaderProgressBlock)progressBlock
                     completed:(nullable SDExternalCompletionBlock)completedBlock;

    Swift

    func sd_setImage(with url: URL?, placeholderImage placeholder: UIImage?, options: SDWebImageOptions = [], context: [SDWebImageContextOption : Any]?, progress progressBlock: SDImageLoaderProgressBlock?, completed completedBlock: SDExternalCompletionBlock? = nil)

    Parameters

    url

    The url for the image.

    placeholder

    The image to be set initially, until the image request finishes.

    options

    The options to use when downloading the image. - see: SDWebImageOptions for the possible values.

    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.

    progressBlock

    A block called while image is downloading - note: the progress block is executed on a background queue

    completedBlock

    A block called when operation has been completed. This block has no return value and takes the requested UIImage as first parameter. In case of error the image parameter is nil and the second parameter may contain an NSError. The third parameter is a Boolean indicating if the image was retrieved from the local cache or from the network. The fourth parameter is the original image url.