Inherits from NSObject
Declared in SDWebImageManager.h
SDWebImageManager.m

Overview

The SDWebImageManager is the class behind the UIImageView+WebCache category and likes. It ties the asynchronous downloader (SDWebImageDownloader) with the image cache store (SDImageCache). You can use this class directly to benefit from web image downloading with caching in another context than a UIView.

Here is a simple example of how to use SDWebImageManager:

SDWebImageManager manager = [SDWebImageManager sharedManager]; [manager downloadWithURL:imageURL delegate:self options:0 progress:nil completed:^(UIImage image, NSError *error, BOOL fromCache) { if (image) { // do something with image } }];

Tasks

Properties

cacheKeyFilter

The cache filter is a block used each time SDWebImageManager need to convert an URL into a cache key. This can be used to remove dynamic part of an image URL.

@property (strong) NSString *^ ) ( NSURL *url ) cacheKeyFilter

Discussion

The cache filter is a block used each time SDWebImageManager need to convert an URL into a cache key. This can be used to remove dynamic part of an image URL.

The following example sets a filter in the application delegate that will remove any query-string from the URL before to use it as a cache key:

[[SDWebImageManager sharedManager] setCacheKeyFilter:^(NSURL *url)
{
    url = [[NSURL alloc] initWithScheme:url.scheme host:url.host path:url.path];
    return [url absoluteString];
}];

Declared In

SDWebImageManager.h

Class Methods

sharedManager

Returns global SDWebImageManager instance.

+ (SDWebImageManager *)sharedManager

Return Value

SDWebImageManager shared instance

Discussion

Returns global SDWebImageManager instance.

Declared In

SDWebImageManager.h

Instance Methods

cancelAll

Cancel all current opreations

- (void)cancelAll

Discussion

Cancel all current opreations

Declared In

SDWebImageManager.h

downloadWithURL:options:progress:completed:

Downloads the image at the given URL if not present in cache or return the cached version otherwise.

- (id<SDWebImageOperation>)downloadWithURL:(NSURL *)url options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletedWithFinishedBlock)completedBlock

Parameters

url

The URL to the image

options

A mask to specify options to use for this request

progressBlock

A block called while image is downloading

completedBlock

A block called when operation has been completed.

This block as 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 retrived from the local cache of from the network.

The last parameter is set to NO when the SDWebImageProgressiveDownload option is used and the image is downloading. This block is thus called repetidly with a partial image. When image is fully downloaded, the block is called a last time with the full image and the last parameter set to YES.

delegate

The delegate object used to send result back

Return Value

Returns a cancellable NSOperation

Discussion

Downloads the image at the given URL if not present in cache or return the cached version otherwise.

Declared In

SDWebImageManager.h

isRunning

Check one or more operations running

- (BOOL)isRunning

Discussion

Check one or more operations running

Declared In

SDWebImageManager.h