From 6d01e80409b88babdfba344fe342de5e113dbeae Mon Sep 17 00:00:00 2001 From: Bogdan Poplauschi Date: Wed, 25 Jun 2014 11:04:28 +0300 Subject: [PATCH] Added comments and coding style to previous pull request #771 --- SDWebImage/UIView+WebCacheOperation.h | 32 ++++++++++++++++++++------- SDWebImage/UIView+WebCacheOperation.m | 18 +++++++-------- 2 files changed, 33 insertions(+), 17 deletions(-) diff --git a/SDWebImage/UIView+WebCacheOperation.h b/SDWebImage/UIView+WebCacheOperation.h index 0e02466..45d6400 100644 --- a/SDWebImage/UIView+WebCacheOperation.h +++ b/SDWebImage/UIView+WebCacheOperation.h @@ -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 + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ #import #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 diff --git a/SDWebImage/UIView+WebCacheOperation.m b/SDWebImage/UIView+WebCacheOperation.m index da60735..64e1ff3 100644 --- a/SDWebImage/UIView+WebCacheOperation.m +++ b/SDWebImage/UIView+WebCacheOperation.m @@ -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 + * + * 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 operation in operations) { @@ -40,7 +40,7 @@ static char loadOperationKey; [operation cancel]; } } - } else { + } else if ([operations conformsToProtocol:@protocol(SDWebImageOperation)]){ [(id) operations cancel]; } [operationDictionary removeObjectForKey:key];