diff --git a/SDWebImage/UIImageView+WebCache.h b/SDWebImage/UIImageView+WebCache.h index 412cca0a..d2992cba 100644 --- a/SDWebImage/UIImageView+WebCache.h +++ b/SDWebImage/UIImageView+WebCache.h @@ -27,8 +27,7 @@ UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier]; if (cell == nil) { - cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier] - autorelease]; + cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier]; } // Here we use the provided sd_setImageWithURL: method to load the web image diff --git a/SDWebImage/UIView+WebCacheOperation.m b/SDWebImage/UIView+WebCacheOperation.m index 19d8b56a..cd769be0 100644 --- a/SDWebImage/UIView+WebCacheOperation.m +++ b/SDWebImage/UIView+WebCacheOperation.m @@ -42,18 +42,21 @@ typedef NSMapTable> SDOperationsDictionary; } - (void)sd_cancelImageLoadOperationWithKey:(nullable NSString *)key { - // Cancel in progress downloader from queue - SDOperationsDictionary *operationDictionary = [self sd_operationDictionary]; - id operation; - @synchronized (self) { - operation = [operationDictionary objectForKey:key]; - } - if (operation) { - if ([operation conformsToProtocol:@protocol(SDWebImageOperation)]){ - [operation cancel]; - } + if (key) { + // Cancel in progress downloader from queue + SDOperationsDictionary *operationDictionary = [self sd_operationDictionary]; + id operation; + @synchronized (self) { - [operationDictionary removeObjectForKey:key]; + operation = [operationDictionary objectForKey:key]; + } + if (operation) { + if ([operation conformsToProtocol:@protocol(SDWebImageOperation)]) { + [operation cancel]; + } + @synchronized (self) { + [operationDictionary removeObjectForKey:key]; + } } } }