ImageDownloaderDelegate
public protocol ImageDownloaderDelegate: class
Protocol of ImageDownloader.
-
imageDownloader(_:didDownload:for:with:)Default implementationCalled when the
ImageDownloaderobject successfully downloaded an image from specified URL.Default Implementation
Declaration
Swift
func imageDownloader(_ downloader: ImageDownloader, didDownload image: Image, for url: URL, with response: URLResponse?)Parameters
downloaderThe
ImageDownloaderobject finishes the downloading.imageDownloaded image.
urlURL of the original request URL.
responseThe response object of the downloading process.
-
imageDownloader(_:willDownloadImageForURL:with:)Default implementationCalled when the
ImageDownloaderobject starts to download an image from specified URL.Default Implementation
Declaration
Swift
func imageDownloader(_ downloader: ImageDownloader, willDownloadImageForURL url: URL, with request: URLRequest?)Parameters
downloaderThe
ImageDownloaderobject starts the downloading.urlURL of the original request.
responseThe request object of the downloading process.
-
isValidStatusCode(_:for:)Default implementationCheck if a received HTTP status code is valid or not. By default, a status code between 200 to 400 (excluded) is considered as valid. If an invalid code is received, the downloader will raise an .invalidStatusCode error. It has a
userInfowhich includes this statusCode and localizedString error message.Note
If the default 200 to 400 valid code does not suit your need, you can implement this method to change that behavior.
Default Implementation
Declaration
Swift
func isValidStatusCode(_ code: Int, for downloader: ImageDownloader) -> BoolParameters
codeThe received HTTP status code.
downloaderThe
ImageDownloaderobject asking for validate status code.Return Value
Whether this HTTP status code is valid or not.
-
imageDownloader(_:didDownload:for:)Default implementationCalled when the
ImageDownloaderobject successfully downloaded image data from specified URL.Note
This callback can be used to preprocess raw image data before creation of UIImage instance (i.e. decrypting or verification).
Default Implementation
Declaration
Swift
func imageDownloader(_ downloader: ImageDownloader, didDownload data: Data, for url: URL) -> Data?Parameters
downloaderThe
ImageDownloaderobject finishes data downloading.dataDownloaded data.
urlURL of the original request URL.
Return Value
The data from which Kingfisher should use to create an image.
View on GitHub
Install in Dash
ImageDownloaderDelegate Protocol Reference