I am trying to find out if an image has already been cached using SDWebImage but when I try to use this method I get the error "Ambiguous reference to member 'cachedIageExistsForURL".
let bool = SDWebImageManager.cachedImageExistsForURL(imgURL)
I am using Swift and I have a bridging header to use the library.
cachedImageExistsForURL
is not a class method on SDWebImageManager
, it's an instance method which you need to use on the sharedInstance
:
SDWebImageManager.sharedManager().cachedImageExistsForURL(imgURL)
As of SDWebImage
5 there is a new class, SDImageCache
, which provides a synchronous method to use:
SDImageCache.shared.diskImageDataExists(withKey: urlString)
There is also an asynchronous method with a completion handler:
SDImageCache.shared.diskImageExists(withKey: urlString) { exists in
// your code here
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With