Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use completion block using SDWebImage in Swift 3.0?

Am using SDWebImage to download image. I want to do further operation if image is downloaded successfully.

cell.appIcon.sd_setImage(with: url, placeholderImage: UIImage.init(named: "App-Default"), completed: {(image: UIImage!, error: NSError!, cacheType: SDImageCacheType, imageURL: URL!) -> Void in
      // Perform operation. 
})

But I am getting error:

Cannot convert value of type '(UIImage!, NSError!, SDImageCacheType, URL!) -> Void' to expected argument type 'SDExternalCompletionBlock?'

like image 608
Parvezkhan Avatar asked Nov 16 '16 05:11

Parvezkhan


1 Answers

Finally solved.

cell.appIcon.sd_setImage(with: url!, placeholderImage: UIImage(named: "App-Default"),options: SDWebImageOptions(rawValue: 0), completed: { (image, error, cacheType, imageURL) in
 // Perform operation.
}) 
like image 147
Parvezkhan Avatar answered Oct 19 '22 06:10

Parvezkhan