SDWebImage checking if image cached using Swift: Ambiguous Reference

Viewed 3252

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.

2 Answers

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
}
Related