Added comments and coding style to previous pull request #771
This commit is contained in:
parent
9b18145e56
commit
6d01e80409
|
|
@ -1,20 +1,36 @@
|
|||
//
|
||||
// UIView+WebCacheOperation.h
|
||||
// SDWebImage
|
||||
//
|
||||
// Created by Whirlwind on 14-5-22.
|
||||
// Copyright (c) 2014年 Dailymotion. All rights reserved.
|
||||
//
|
||||
/*
|
||||
* This file is part of the SDWebImage package.
|
||||
* (c) Olivier Poitrey <rs@dailymotion.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "SDWebImageManager.h"
|
||||
|
||||
@interface UIView (WebCacheOperation)
|
||||
|
||||
- (void)setImageLoadOperation:(id)operation forKey:(NSString *)Key;
|
||||
/**
|
||||
* Set the image load operation (storage in a UIView based dictionary)
|
||||
*
|
||||
* @param operation the operation
|
||||
* @param key key for storing the operation
|
||||
*/
|
||||
- (void)setImageLoadOperation:(id)operation forKey:(NSString *)key;
|
||||
|
||||
/**
|
||||
* Cancel all operations for the current UIView and key
|
||||
*
|
||||
* @param key key for identifying the operations
|
||||
*/
|
||||
- (void)cancelImageLoadOperationWithKey:(NSString *)key;
|
||||
|
||||
/**
|
||||
* Just remove the operations corresponding to the current UIView and key without cancelling them
|
||||
*
|
||||
* @param key key for identifying the operations
|
||||
*/
|
||||
- (void)removeImageLoadOperationWithKey:(NSString *)key;
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
//
|
||||
// UIView+WebCacheOperation.m
|
||||
// SDWebImage
|
||||
//
|
||||
// Created by Whirlwind on 14-5-22.
|
||||
// Copyright (c) 2014年 Dailymotion. All rights reserved.
|
||||
//
|
||||
/*
|
||||
* This file is part of the SDWebImage package.
|
||||
* (c) Olivier Poitrey <rs@dailymotion.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
#import "UIView+WebCacheOperation.h"
|
||||
#import "objc/runtime.h"
|
||||
|
|
@ -32,7 +32,7 @@ static char loadOperationKey;
|
|||
- (void)cancelImageLoadOperationWithKey:(NSString *)key {
|
||||
// Cancel in progress downloader from queue
|
||||
NSMutableDictionary *operationDictionary = [self operationDictionary];
|
||||
id operations = [operationDictionary objectForKey:key];
|
||||
id operations = [operationDictionary objectForKey:key];
|
||||
if (operations) {
|
||||
if ([operations isKindOfClass:[NSArray class]]) {
|
||||
for (id <SDWebImageOperation> operation in operations) {
|
||||
|
|
@ -40,7 +40,7 @@ static char loadOperationKey;
|
|||
[operation cancel];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
} else if ([operations conformsToProtocol:@protocol(SDWebImageOperation)]){
|
||||
[(id<SDWebImageOperation>) operations cancel];
|
||||
}
|
||||
[operationDictionary removeObjectForKey:key];
|
||||
|
|
|
|||
Loading…
Reference in New Issue