LuxChat  2.0
Instant messenger for iOS
Instance Methods | Class Methods | Properties | List of all members
SDWebImageManager Class Reference

#import <SDWebImageManager.h>

Inheritance diagram for SDWebImageManager:

Instance Methods

(id< SDWebImageOperation >) - downloadImageWithURL:options:progress:completed:
 
(void) - saveImageToCache:forURL:
 
(void) - cancelAll
 
(BOOL) - isRunning
 
(BOOL) - cachedImageExistsForURL:
 
(BOOL) - diskImageExistsForURL:
 
(void) - cachedImageExistsForURL:completion:
 
(void) - diskImageExistsForURL:completion:
 
(NSString *) - cacheKeyForURL:
 
(id< SDWebImageOperation >) - downloadWithURL:options:progress:completed:
 

Class Methods

(SDWebImageManager *) + sharedManager
 

Properties

id< SDWebImageManagerDelegatedelegate
 
SDImageCacheimageCache
 
SDWebImageDownloaderimageDownloader
 
SDWebImageCacheKeyFilterBlock cacheKeyFilter
 

Detailed Description

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:

[manager downloadImageWithURL:imageURL
options:0
progress:nil
completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
if (image) {
// do something with image
}
}];

Method Documentation

- (BOOL) cachedImageExistsForURL: (NSURL *)  url

Check if image has already been cached

Parameters
urlimage url
Returns
if the image was already cached
- (void) cachedImageExistsForURL: (NSURL *)  url
completion: (SDWebImageCheckCacheCompletionBlock)  completionBlock 

Async check if image has already been cached

Parameters
urlimage url
completionBlockthe block to be executed when the check is finished
Note
the completion block is always executed on the main queue
- (NSString *) cacheKeyForURL: (NSURL *)  url

Return the cache key for a given URL

- (void) cancelAll

Cancel all current opreations

- (BOOL) diskImageExistsForURL: (NSURL *)  url

Check if image has already been cached on disk only

Parameters
urlimage url
Returns
if the image was already cached (disk only)
- (void) diskImageExistsForURL: (NSURL *)  url
completion: (SDWebImageCheckCacheCompletionBlock)  completionBlock 

Async check if image has already been cached on disk only

Parameters
urlimage url
completionBlockthe block to be executed when the check is finished
Note
the completion block is always executed on the main queue
- (id< SDWebImageOperation >) downloadImageWithURL: (NSURL *)  url
options: (SDWebImageOptions)  options
progress: (SDWebImageDownloaderProgressBlock)  progressBlock
completed: (SDWebImageCompletionWithFinishedBlock)  completedBlock 

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

Parameters
urlThe URL to the image
optionsA mask to specify options to use for this request
progressBlockA block called while image is downloading
completedBlockA block called when operation has been completed.

This parameter is required.

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 an SDImageCacheType enum indicating if the image was retrived from the local cache or from the memory cache or 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.

Returns
Returns an NSObject conforming to SDWebImageOperation. Should be an instance of SDWebImageDownloaderOperation
- (id <SDWebImageOperation>) downloadWithURL: (NSURL *)  url
options: (SDWebImageOptions)  options
progress: (SDWebImageDownloaderProgressBlock)  progressBlock
completed: ("Method deprecated. Use `downloadImageWithURL:options:progress:completed:`")  __deprecated_msg 

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

Deprecated:
This method has been deprecated. Use downloadImageWithURL:options:progress:completed:

Provided by category SDWebImageManager(Deprecated).

- (BOOL) isRunning

Check one or more operations running

- (void) saveImageToCache: (UIImage *)  image
forURL: (NSURL *)  url 

Saves image to cache for given URL

Parameters
imageThe image to cache
urlThe URL to the image
+ (id) sharedManager

Returns global SDWebImageManager instance.

Returns
SDWebImageManager shared instance

Property Documentation

- (SDWebImageCacheKeyFilterBlock) cacheKeyFilter
readwritenonatomiccopy

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];
}];

The documentation for this class was generated from the following files: