Kingfisher: Loading an image directly into a UIImage rather than a UIImageView

Created on 15 Jul 2016  路  4Comments  路  Source: onevcat/Kingfisher

Is it possible to download image into a uiimage instead of UIImageView?
I have a scene where I need to set the same image from a URL into 2 different UIImageViews.
So to avoid network usage I thought I could have 1 UIImage and then add didSet to it.

Most helpful comment

@Elshad No, it will not be added to downloader, since the downloader should not know anything about cache.

Instead, you could try the methods of KingfisherManager, in which a method taking care of both download and cache contained.

All 4 comments

I think that ImageDownloader is the perfect choice for you.
ImageDownloader.defaultDownloader.downloadImageWithURL(URL: progressBlock:completionHandler)

@alessandro-martin Thanks for the answer.
It's true that you could get the image without setting to an image view. However, you might lose the cache part if you just use downloader standalone as well. (You may need to call the cache methods yourself)

@Minitour For your case, there is no worry about network usage. Kingfisher is smart enough to recognize that this image url is already in downloading progress. It will not start another download when you try to set a same url to the second image view. Once the download finishes, both of your image views will be set.

@onevcat Are you planning to add automatically cache to downloader standalone?

@Elshad No, it will not be added to downloader, since the downloader should not know anything about cache.

Instead, you could try the methods of KingfisherManager, in which a method taking care of both download and cache contained.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

litt1e-p picture litt1e-p  路  4Comments

nickgate picture nickgate  路  4Comments

Tarpsvo picture Tarpsvo  路  5Comments

wudijimao picture wudijimao  路  3Comments

vCrespoP picture vCrespoP  路  3Comments