Skip to content

Commit

Permalink
Set the webURL to nil for nil resources
Browse files Browse the repository at this point in the history
Delete the associated WebURL when a nil `Resource` is set on an ImageView.
This should prevent that the imageView is updated with the wrong image if a download previously started completes after the image is set again to nil.
  • Loading branch information
pNre authored Feb 20, 2017
1 parent 1add8d8 commit 55a9ca4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Sources/ImageView+Kingfisher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ extension Kingfisher where Base: ImageView {
{
guard let resource = resource else {
base.image = placeholder
setWebURL(nil)
completionHandler?(nil, nil, .none, nil)
return .empty
}
Expand Down Expand Up @@ -155,7 +156,7 @@ extension Kingfisher where Base: ImageView {
return objc_getAssociatedObject(base, &lastURLKey) as? URL
}

fileprivate func setWebURL(_ url: URL) {
fileprivate func setWebURL(_ url: URL?) {
objc_setAssociatedObject(base, &lastURLKey, url, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
}

Expand Down

0 comments on commit 55a9ca4

Please sign in to comment.