问题
How I can change a static value cacheMaxCacheAge
when I use SDWebImage? What way is good? I need to cache images for 5 minutes.
回答1:
In SDWebImage 5.0+ maxCacheAge renamed to maxDiskAge. You can set maximum caching time in seconds like this.
Objetive-c
[SDImageCache sharedImageCache].config.maxDiskSize = 60 * 5; //5 minutes
Swift 4+
SDImageCache.shared.config.maxDiskAge = 60 * 5 //5 minutes
Reference link: https://github.com/SDWebImage/SDWebImage/wiki/5.0-Migration-guide
回答2:
SDWebImage is providing maxCacheAge
property to set the maximum caching time in seconds. We can use shared instance method to access this property.
[SDImageCache sharedImageCache].config.maxCacheAge = 60 * 5; //5 minutes
来源:https://stackoverflow.com/questions/28549211/sdwebimage-change-cachemaxcacheage