Make callbacks of download more readable
This commit is contained in:
parent
65f72743cc
commit
30d077b0a6
|
@ -105,15 +105,10 @@ typedef NSMutableDictionary<NSString *, id> SDCallbacksDictionary;
|
||||||
|
|
||||||
- (nullable NSArray<id> *)callbacksForKey:(NSString *)key {
|
- (nullable NSArray<id> *)callbacksForKey:(NSString *)key {
|
||||||
LOCK(self.callbacksLock);
|
LOCK(self.callbacksLock);
|
||||||
NSArray<SDCallbacksDictionary *> *callbackBlocks = [self.callbackBlocks copy];
|
NSMutableArray<id> *callbacks = [[self.callbackBlocks valueForKey:key] mutableCopy];
|
||||||
UNLOCK(self.callbacksLock);
|
UNLOCK(self.callbacksLock);
|
||||||
NSMutableArray<id> *callbacks = [NSMutableArray arrayWithCapacity:callbackBlocks.count];
|
// We need to remove [NSNull null] because there might not always be a progress block for each callback
|
||||||
for (SDCallbacksDictionary *callbacksDic in callbackBlocks) {
|
[callbacks removeObjectIdenticalTo:[NSNull null]];
|
||||||
id callback = callbacksDic[key];
|
|
||||||
if (callback) {
|
|
||||||
[callbacks addObject:callback];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return [callbacks copy]; // strip mutability here
|
return [callbacks copy]; // strip mutability here
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue