Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SDWebImage, Swift: SDWebImageRefreshCached unresolved identifier

Strange.. something simple that is in the docs doesn't seem to work with Swift. See below code. Where exactly is "SDWebImageRefreshCached" when using Swift??

self.profileImageView.sd_setImageWithURL(profileImageUrl, placeholderImage:  UIImage(named: "default_profile_image"), options: SDWebImageRefreshCached)
like image 266
skippyman Avatar asked Jul 25 '26 09:07

skippyman


2 Answers

In Swift, the enums are exposed slightly differently.

You would be looking for SDWebImageOptions.RefreshCached, or .RefreshCached for short.

Your line of code thus would be:

self.profileImageView.sd_setImageWithURL(profileImageUrl, placeholderImage:  UIImage(named: "default_profile_image"), options: .RefreshCached)
like image 172
Edward Jiang Avatar answered Jul 28 '26 04:07

Edward Jiang


You can try this code:

.RefreshCached is change to .refreshCached in SDWebImage 4.0.0

//SDWebImage 4.0.0
self.profileImageView.sd_setImage(with: yourImageUrl, placeholderImage: UIImage("Your placeholder image name"), options: .refreshCached)
like image 36
Andrian Rahardja Avatar answered Jul 28 '26 05:07

Andrian Rahardja