|
LuxChat
2.0
Instant messenger for iOS
|
#import <SDWebImageManager.h>
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< SDWebImageManagerDelegate > | delegate |
| SDImageCache * | imageCache |
| SDWebImageDownloader * | imageDownloader |
| SDWebImageCacheKeyFilterBlock | cacheKeyFilter |
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:
| - (BOOL) cachedImageExistsForURL: | (NSURL *) | url |
Check if image has already been cached
| url | image url |
| - (void) cachedImageExistsForURL: | (NSURL *) | url | |
| completion: | (SDWebImageCheckCacheCompletionBlock) | completionBlock | |
Async check if image has already been cached
| url | image url |
| completionBlock | the block to be executed when the check is finished |
| - (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
| url | image url |
| - (void) diskImageExistsForURL: | (NSURL *) | url | |
| completion: | (SDWebImageCheckCacheCompletionBlock) | completionBlock | |
Async check if image has already been cached on disk only
| url | image url |
| completionBlock | the block to be executed when the check is finished |
| - (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.
| 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 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.
| - (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.
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
| image | The image to cache |
| url | The URL to the image |
| + (id) sharedManager |
Returns global SDWebImageManager instance.
|
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:
1.8.9.1