Merge pull request #400 from BB9z/fix/document-parameter

Some document improves.
This commit is contained in:
Olivier Poitrey 2013-05-27 09:53:45 -07:00
commit e8c5ed17c0
4 changed files with 73 additions and 60 deletions

View File

@ -82,8 +82,8 @@ typedef void(^SDWebImageDownloaderCompletedBlock)(UIImage *image, NSData *data,
*
* @param url The URL to the image to download
* @param options The options to be used for this download
* @param progress A block called repeatedly while the image is downloading
* @param completed A block called once the download is completed.
* @param progressBlock A block called repeatedly while the image is downloading
* @param completedBlock A block called once the download is completed.
* If the download succeeded, the image parameter is set, in case of error,
* error parameter is set with the error. The last parameter is always YES
* if SDWebImageDownloaderProgressiveDownload isn't use. With the

View File

@ -85,18 +85,21 @@ typedef void(^SDWebImageCompletedWithFinishedBlock)(UIImage *image, NSError *err
*
* 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
* }
* }];
* @code
SDWebImageManager *manager = [SDWebImageManager sharedManager];
[manager downloadWithURL:imageURL
options:0
progress:nil
completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished)
{
if (image)
{
// do something with image
}
}];
* @endcode
*/
@interface SDWebImageManager : NSObject
@ -112,11 +115,15 @@ typedef void(^SDWebImageCompletedWithFinishedBlock)(UIImage *image, NSError *err
* 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];
* }];
* @code
[[SDWebImageManager sharedManager] setCacheKeyFilter:^(NSURL *url)
{
url = [[NSURL alloc] initWithScheme:url.scheme host:url.host path:url.path];
return [url absoluteString];
}];
* @endcode
*/
@property (strong) NSString *(^cacheKeyFilter)(NSURL *url);
@ -131,7 +138,6 @@ typedef void(^SDWebImageCompletedWithFinishedBlock)(UIImage *image, NSError *err
* Downloads the image at the given URL if not present in cache or return the cached version otherwise.
*
* @param url The URL to the image
* @param delegate The delegate object used to send result back
* @param options A mask to specify options to use for this request
* @param progressBlock A block called while image is downloading
* @param completedBlock A block called when operation has been completed.
@ -139,13 +145,12 @@ typedef void(^SDWebImageCompletedWithFinishedBlock)(UIImage *image, NSError *err
* 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 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.
* 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.
*
* @return Returns a cancellable NSOperation
*/

View File

@ -134,8 +134,10 @@
*
* @param url The url for the image.
* @param state The state that uses the specified title. The values are described in UIControlState.
* @param success A block to be executed when the image request succeed This block has no return value and takes the retrieved image as argument.
* @param failure A block object to be executed when the image request failed. This block has no return value and takes the error object describing the network or parsing error that occurred (may be nil).
* @param completedBlock A block object to be executed after the request operation
* completed. This block has no return value and takes three argument: the requested
* `UIImage` object, the `NSError` object describing error that occurred, and an
* `SDImageCacheType` enum describing the source of the image obtained from.
*/
- (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state completed:(SDWebImageCompletedBlock)completedBlock;
@ -147,8 +149,10 @@
* @param url The url for the image.
* @param state The state that uses the specified title. The values are described in UIControlState.
* @param placeholder The image to be set initially, until the image request finishes.
* @param success A block to be executed when the image request succeed This block has no return value and takes the retrieved image as argument.
* @param failure A block object to be executed when the image request failed. This block has no return value and takes the error object describing the network or parsing error that occurred (may be nil).
* @param completedBlock A block object to be executed after the request operation
* completed. This block has no return value and takes three argument: the requested
* `UIImage` object, the `NSError` object describing error that occurred, and an
* `SDImageCacheType` enum describing the source of the image obtained from.
*/
- (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock;
@ -160,8 +164,10 @@
* @param url The url for the image.
* @param placeholder The image to be set initially, until the image request finishes.
* @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values.
* @param success A block to be executed when the image request succeed This block has no return value and takes the retrieved image as argument.
* @param failure A block object to be executed when the image request failed. This block has no return value and takes the error object describing the network or parsing error that occurred (may be nil).
* @param completedBlock A block object to be executed after the request operation
* completed. This block has no return value and takes three argument: the requested
* `UIImage` object, the `NSError` object describing error that occurred, and an
* `SDImageCacheType` enum describing the source of the image obtained from.
*/
- (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock;

View File

@ -14,32 +14,34 @@
*
* Usage with a UITableViewCell sub-class:
*
* #import <SDWebImage/UIImageView+WebCache.h>
*
* ...
*
* - (UITableViewCell *)tableView:(UITableView *)tableView
* cellForRowAtIndexPath:(NSIndexPath *)indexPath
* {
* static NSString *MyIdentifier = @"MyIdentifier";
*
* UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
*
* if (cell == nil)
* {
* cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
* reuseIdentifier:MyIdentifier] autorelease];
* }
*
* // Here we use the provided setImageWithURL: method to load the web image
* // Ensure you use a placeholder image otherwise cells will be initialized with no image
* [cell.imageView setImageWithURL:[NSURL URLWithString:@"http://example.com/image.jpg"]
* placeholderImage:[UIImage imageNamed:@"placeholder"]];
*
* cell.textLabel.text = @"My Text";
* return cell;
* }
*
* @code
#import <SDWebImage/UIImageView+WebCache.h>
...
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *MyIdentifier = @"MyIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier]
autorelease];
}
// Here we use the provided setImageWithURL: method to load the web image
// Ensure you use a placeholder image otherwise cells will be initialized with no image
[cell.imageView setImageWithURL:[NSURL URLWithString:@"http://example.com/image.jpg"]
placeholderImage:[UIImage imageNamed:@"placeholder"]];
cell.textLabel.text = @"My Text";
return cell;
}
* @endcode
*/
@interface UIImageView (WebCache)