ImageDownloader
open class ImageDownloader
ImageDownloader represents a downloading manager for requesting the image with a URL from server.
-
The duration before the download is timeout. Default is 15 seconds.
Declaration
Swift
open var downloadTimeout: TimeInterval = 15.0 -
A set of trusted hosts when receiving server trust challenges. A challenge with host name contained in this set will be ignored. You can use this set to specify the self-signed site. It only will be used if you don’t specify the
authenticationChallengeResponder. IfauthenticationChallengeResponderis set, this property will be ignored and the implemention ofauthenticationChallengeResponderwill be used instead.Declaration
Swift
open var trustedHosts: Set<String>? -
Use this to set supply a configuration for the downloader. By default, NSURLSessionConfiguration.ephemeralSessionConfiguration() will be used. You could change the configuration before a downloaing task starts. A configuration without persistent storage for caches is requsted for downloader working correctly.
Declaration
Swift
open var sessionConfiguration = URLSessionConfiguration.ephemeral -
Whether the download requests should use pipeling or not. Default is false.
Declaration
Swift
open var requestsUsePipelining = false -
Delegate of this
ImageDownloaderobject. SeeImageDownloaderDelegateprotocol for more.Declaration
Swift
open weak var delegate: ImageDownloaderDelegate? -
A responder for authentication challenge. Downloader will forward the received authentication challenge for the downloading session to this responder.
Declaration
Swift
open weak var authenticationChallengeResponder: AuthenticationChallengeResponsable?
-
The default downloader.
Declaration
Swift
public static let `default` = ImageDownloader(name: "default") -
Init a downloader with name.
Declaration
Swift
public init(name: String)Parameters
nameThe name for the downloader. It should not be empty.
Return Value
The downloader object.
-
Download an image with a URL and option.
Declaration
Swift
open func downloadImage(with url: URL, retrieveImageTask: RetrieveImageTask? = nil, options: KingfisherOptionsInfo? = nil, progressBlock: ImageDownloaderProgressBlock? = nil, completionHandler: ImageDownloaderCompletionHandler? = nil) -> RetrieveImageDownloadTask?Parameters
urlTarget URL.
retrieveImageTaskThe task to cooporate with cache. Pass
nilif you are not trying to use downloader and cache.optionsThe options could control download behavior. See
KingfisherOptionsInfo.progressBlockCalled when the download progress updated.
completionHandlerCalled when the download progress finishes.
Return Value
A downloading task. You could call
cancelon it to stop the downloading process.
View on GitHub
Install in Dash
ImageDownloader Class Reference