Closed pfcstyle closed 2 years ago
@pfcstyle Try to debug on this line of code SDWebImageManger.m:375
to see whether this is a BUG or something wrong :
And for your use case, actually you can use another feature request modifier, to override the URLRequest's headers (to append your access token).
Thank you @dreampiggy . I found why it doesn't work.
I set defaultLoader
after setting cacheKeyFilter
. SDWebImageManager.shared
call its init
method to set imageLoader
property, but defaultImageLoader
is NULL this time. So we must set defaultImageLoader
before SDWebImageManager
firstly init.
// bad code
SDWebImageManager.shared.cacheKeyFilter = SDWebImageCacheKeyFilter(block: { (url) -> String? in
return url.getSDCacheKey()
})
SDImageLoadersManager.shared.loaders = [AGSSDImageLoader.shared, SDWebImageDownloader.shared]
SDWebImageManager.defaultImageLoader = SDImageLoadersManager.shared
//work code
SDImageLoadersManager.shared.addLoader(AGSSDImageLoader.shared)
SDWebImageManager.defaultImageLoader = SDImageLoadersManager.shared
SDWebImageManager.shared.cacheKeyFilter = SDWebImageCacheKeyFilter(block: { (url) -> String? in
return url.getSDCacheKey()
})
By the way, request modifier is not suitable for me, because I can't get my access token directly. Thanks for your advice.
I'm using a third-party framework named ArcGIS and I can't get authentication token from the framework, so I have to custom a image loader to use its download method to download image.
The code is below:
And I add the loader in
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool
:There is no any output from the
AGSSDImageLoader
, and image is loaded like that loaders containsSDWebImageDownloader
only.Thanks!