Skip to content

Commit

Permalink
Added comments and coding style to previous pull request #771
Browse files Browse the repository at this point in the history
  • Loading branch information
bpoplauschi committed Jun 25, 2014
1 parent 9b18145 commit 6d01e80
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 17 deletions.
32 changes: 24 additions & 8 deletions SDWebImage/UIView+WebCacheOperation.h
Original file line number Diff line number Diff line change
@@ -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
18 changes: 9 additions & 9 deletions SDWebImage/UIView+WebCacheOperation.m
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -32,15 +32,15 @@ - (void)setImageLoadOperation:(id)operation forKey:(NSString *)key {
- (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) {
if (operation) {
[operation cancel];
}
}
} else {
} else if ([operations conformsToProtocol:@protocol(SDWebImageOperation)]){
[(id<SDWebImageOperation>) operations cancel];
}
[operationDictionary removeObjectForKey:key];
Expand Down

0 comments on commit 6d01e80

Please sign in to comment.