Fix the support for `SDImageLoadersManager` for canRequest API check, should be compatible with both old and new API

This commit is contained in:
lizhuoli 2021-10-18 21:30:34 +08:00
parent a72df48494
commit 4274158949
1 changed files with 12 additions and 2 deletions

View File

@ -78,12 +78,22 @@
#pragma mark - SDImageLoader
- (BOOL)canRequestImageForURL:(nullable NSURL *)url {
return [self canRequestImageForURL:url options:0 context:nil];
}
- (BOOL)canRequestImageForURL:(NSURL *)url options:(SDWebImageOptions)options context:(SDWebImageContext *)context {
NSArray<id<SDImageLoader>> *loaders = self.loaders;
for (id<SDImageLoader> loader in loaders.reverseObjectEnumerator) {
if ([loader respondsToSelector:@selector(canRequestImageForURL:options:context:)]) {
if ([loader canRequestImageForURL:url options:options context:context]) {
return YES;
}
} else {
if ([loader canRequestImageForURL:url]) {
return YES;
}
}
}
return NO;
}