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
. IfauthenticationChallengeResponder
is set, this property will be ignored and the implemention ofauthenticationChallengeResponder
will 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
ImageDownloader
object. SeeImageDownloaderDelegate
protocol 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
name
The 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
url
Target URL.
retrieveImageTask
The task to cooporate with cache. Pass
nil
if you are not trying to use downloader and cache.options
The options could control download behavior. See
KingfisherOptionsInfo
.progressBlock
Called when the download progress updated.
completionHandler
Called when the download progress finishes.
Return Value
A downloading task. You could call
cancel
on it to stop the downloading process.