Added method to SDWebImageManager to check if an image exists in either the disk OR the memory cache

This commit is contained in:
Ken Chatfield 2014-02-27 21:07:00 +00:00
parent 5f3e9272c8
commit 25d20ead49
2 changed files with 7 additions and 0 deletions

View File

@ -190,6 +190,7 @@ SDWebImageManager *manager = [SDWebImageManager sharedManager];
/**
* Check if image has already been cached
*/
- (BOOL)cachedImageExistsForURL:(NSURL *)url;
- (BOOL)diskImageExistsForURL:(NSURL *)url;
@end

View File

@ -60,6 +60,12 @@
}
}
- (BOOL)cachedImageExistsForURL:(NSURL *)url {
NSString *key = [self cacheKeyForURL:url];
if ([self.imageCache imageFromMemoryCacheForKey:key] != nil) return YES;
return [self.imageCache diskImageExistsWithKey:key];
}
- (BOOL)diskImageExistsForURL:(NSURL *)url {
NSString *key = [self cacheKeyForURL:url];
return [self.imageCache diskImageExistsWithKey:key];