Merge pull request #2386 from zhongwuzw/fix-nullable
Fix nullable key when cancel image load operation
This commit is contained in:
commit
dbbfbd715a
|
@ -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
|
||||
|
|
|
@ -42,18 +42,21 @@ typedef NSMapTable<NSString *, id<SDWebImageOperation>> SDOperationsDictionary;
|
|||
}
|
||||
|
||||
- (void)sd_cancelImageLoadOperationWithKey:(nullable NSString *)key {
|
||||
// Cancel in progress downloader from queue
|
||||
SDOperationsDictionary *operationDictionary = [self sd_operationDictionary];
|
||||
id<SDWebImageOperation> 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<SDWebImageOperation> operation;
|
||||
|
||||
@synchronized (self) {
|
||||
[operationDictionary removeObjectForKey:key];
|
||||
operation = [operationDictionary objectForKey:key];
|
||||
}
|
||||
if (operation) {
|
||||
if ([operation conformsToProtocol:@protocol(SDWebImageOperation)]) {
|
||||
[operation cancel];
|
||||
}
|
||||
@synchronized (self) {
|
||||
[operationDictionary removeObjectForKey:key];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue