AirImageCache
public struct AirImageCache
AirImageCache saves and returns images from an NSCache stored in memory and in the /Caches
directory.
-
If provided, AirImageCache will log messages to this function
Declaration
Swift
public static var log: ((_ message: String, _ file: String, _ function: String, _ line: Int) -> Void)?
-
An object conforming to
AirImageURLProviding
will allow the AirImageCache to download images from the url from the providerDeclaration
Swift
public static var imageURLProvider: AirImageURLProviding?
-
Checks all cache locations for a UIImage matching the
key
.Declaration
Swift
@discardableResult public static func image(for key: String, file: String = #file, function: String = #function, line: Int = #line, completion: @escaping (UIImage?) -> Void) -> URLSessionDataTask?
Parameters
key
Unique identifier for an image.
completion
Function that executes when the image is found, or the imagecache gives up looking. Dispatches to main thread so safe for UI.
Return Value
Optional URLSessionDataTask, if you want to keep track and cancel early.
-
Saves a provided image into the cache.
Declaration
Swift
public static func save(_ image: UIImage, for key: String, file: String = #file, function: String = #function, line: Int = #line) -> Void
Parameters
image
UIImage to save to the in memory cache and filesystem.
key
Unique identifier for an image.
-
Cancels all in progress image downloads
Declaration
Swift
public static func cancelAllDownloads()