diff --git a/SDWebImage/SDWebImageDownloaderOperation.m b/SDWebImage/SDWebImageDownloaderOperation.m index 2690beab..a6c13fa7 100644 --- a/SDWebImage/SDWebImageDownloaderOperation.m +++ b/SDWebImage/SDWebImageDownloaderOperation.m @@ -105,15 +105,10 @@ typedef NSMutableDictionary SDCallbacksDictionary; - (nullable NSArray *)callbacksForKey:(NSString *)key { LOCK(self.callbacksLock); - NSArray *callbackBlocks = [self.callbackBlocks copy]; + NSMutableArray *callbacks = [[self.callbackBlocks valueForKey:key] mutableCopy]; UNLOCK(self.callbacksLock); - NSMutableArray *callbacks = [NSMutableArray arrayWithCapacity:callbackBlocks.count]; - for (SDCallbacksDictionary *callbacksDic in callbackBlocks) { - id callback = callbacksDic[key]; - if (callback) { - [callbacks addObject:callback]; - } - } + // We need to remove [NSNull null] because there might not always be a progress block for each callback + [callbacks removeObjectIdenticalTo:[NSNull null]]; return [callbacks copy]; // strip mutability here }