I need the completion handler functionality of SDWebImageManager (to set the downloaded or cached image black and white), so I'm using it instead of sd_setimage. My issue is that I can't figure out how to use SDWebImageManager to download OR get the cached version of the image. The image re-downloads each time a tableview cell is dequeued and reloaded. I tried setting options: SDWebImageDownloaderOptions.useNSURLCache, but to no avail. Any suggestions would be greatly appreciated! Here's my code:
SDWebImageManager.shared().imageDownloader?.downloadImage(with:URL(string: imgURL), options: SDWebImageDownloaderOptions.useNSURLCache, progress: nil, completed: { (image, error, cacheType, url) in
if image != nil {
let beginImage = CIImage(image: image!)
let blackNwhiteImg = beginImage?.applyingFilter("CIColorControls", withInputParameters: [kCIInputSaturationKey:0.0])
let newImage = UIImage(ciImage: blackNwhiteImg!)
cell.button.setImage(newImage, for: .normal)
}
})