Kingfisher: Update new image not work
Check List
Thanks for considering to open an issue. Before you submit your issue, please confirm these boxes are checked.
- I have read the wiki page and cheat sheet, but there is no information I need.
- I have searched in existing issues, but did find a same one.
- I want to reoprt a problem instead of asking a question. It’d better to use kingfisher tag in Stack Overflow to ask a question.
Issue Description
I have an avatar and want to update it, after I upload a new image and get a new URL, then the setImage function still gives me the old one. This code is triggered whenever it has a new URL.
let url = URL(string: profile.avatar60 ?? "")
avatarImageView.kf.setImage(with: url, placeholder: #imageLiteral(resourceName: "ic_profile_default"), options: [.transition(ImageTransition.fade(0.5))])
Then I cheat with this way to work (but some time it does not work)
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5, execute: {
let url = URL(string: profile.avatar60 ?? "")
me.avatarImageView.kf.setImage(with: url, placeholder: #imageLiteral(resourceName: "ic_profile_default"), options: [.forceRefresh, .transition(ImageTransition.fade(0.5))])
})
So what is the exactly problem?
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 20 (7 by maintainers)
@abdulKarim002
Hi, thanks for this. But the race condition should be already fixed.
In addition, there is an Swift Access Race issue in the below function in ImageDownloader.swift
func clean(for url: URL) { barrierQueue.sync(flags: .barrier) { fetchLoads.removeValue(forKey: url) return } }