Get UIImage only with Kingfisher library
You could use the retrieveImage(with:options:progressBlock: completionHandler:)
method of KingfisherManager
for this.
Maybe something like this:
KingfisherManager.shared.retrieveImage(with: url, options: nil, progressBlock: nil, completionHandler: { image, error, cacheType, imageURL in print(image)})
This is latest syntax to download image in kingFisher 5 (Tested in swift 4.2)
func downloadImage(`with` urlString : String){ guard let url = URL.init(string: urlString) else { return } let resource = ImageResource(downloadURL: url) KingfisherManager.shared.retrieveImage(with: resource, options: nil, progressBlock: nil) { result in switch result { case .success(let value): print("Image: \(value.image). Got from: \(value.cacheType)") case .failure(let error): print("Error: \(error)") } }}
How to call above function
self.downloadImage(with: imageURL) //replace with your image url
With the new Swift 3 version you can use ImageDownloader :
ImageDownloader.default.downloadImage(with: url, options: [], progressBlock: nil) { (image, error, url, data) in print("Downloaded Image: \(image)")}
ImageDownloader
is a part of Kingfisher so don't forget to import Kingfisher
.