Skip to content

Commit

Permalink
Capture self weakly inside completion block
Browse files Browse the repository at this point in the history
  • Loading branch information
vfn committed Jul 9, 2015
1 parent 6f8b1b1 commit 835df55
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions Kingfisher/UIImageView+Kingfisher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,14 @@ public extension UIImageView {
progressBlock(receivedSize: receivedSize, totalSize: totalSize)
})
}
}) { (image, error, cacheType, imageURL) -> () in
dispatch_async(dispatch_get_main_queue(), { () -> Void in
if (imageURL == self.kf_webURL && image != nil) {
self.image = image;
}
completionHandler?(image: image, error: error, cacheType:cacheType, imageURL: imageURL)
}, completionHandler: {[weak self] (image, error, cacheType, imageURL) -> () in
dispatch_async(dispatch_get_main_queue(), { () -> Void in
if let sSelf = self where imageURL == sSelf.kf_webURL && image != nil {
sSelf.image = image;
}
completionHandler?(image: image, error: error, cacheType:cacheType, imageURL: imageURL)
})
})
}

return task
}
Expand Down

0 comments on commit 835df55

Please sign in to comment.