Manju Basha Manju Basha - 1 month ago 12x
Swift Question

Not able to cache image using method downloadImageWithURL in SDWebImageManager

I am using the code given below to download the image using

method and to assign the image to a
and cache the same image using
, but i am not able to cache the image. Am i missing anything?

Here is my code:

options: SDWebImageOptions.HighPriority,
progress: { (min:Int, max:Int) -> Void in
{ (image:UIImage!, error:NSError!, cacheType:SDImageCacheType, finished:Bool, url:NSURL!) -> Void in
if (image != nil)
self.userProfilePic.image = image
SDImageCache.sharedImageCache().storeImage(image, forKey: "userProfilePicImage", toDisk: true)



SDWebImage has a Method sd_setImageWithURL which will download the image and save it to Cache also, you don't need to manually save that image on Cache

Try below code it will solve your problem

self.userProfilePic.sd_setImageWithURL(NSURL(string: "")!, placeholderImage: UIImage(named: "placeholder.png")!)