Fix the logic to check loaders. Find the correct loader first and then check if optional protocol method is implemented

This commit is contained in:
DreamPiggy 2019-04-02 16:32:15 +08:00
parent fa426f9b05
commit 691873117a
1 changed files with 5 additions and 4 deletions

View File

@ -103,11 +103,12 @@
- (BOOL)shouldBlockFailedURLWithURL:(NSURL *)url error:(NSError *)error {
NSArray<id<SDImageLoader>> *loaders = self.loaders;
for (id<SDImageLoader> loader in loaders.reverseObjectEnumerator) {
if (![loader respondsToSelector:@selector(shouldBlockFailedURLWithURL:error:)]) {
break;
}
if ([loader canRequestImageForURL:url]) {
return [loader shouldBlockFailedURLWithURL:url error:error];
if ([loader respondsToSelector:@selector(shouldBlockFailedURLWithURL:error:)]) {
return [loader shouldBlockFailedURLWithURL:url error:error];
} else {
return NO;
}
}
}
return NO;