URLImageView
The URLImageView takes care of downloading images from external servers, caching the image after the download completes, and of course displaying in its image property.
The simplest of the URLImageView
initializers
accepts a delegate
(More on this later),
and the sourceURLString
.
Simply pass in the URL of the image, and it will be fetched and displayed.
let urlString = "https://picsum.photos/400/800/?random"
let imageView = URLImageView(delegate: nil, sourceURLString: urlString)
imageView.contentMode = .scaleAspectFill
imageView.layer.cornerRadius = 10

Other Initializers
While this simple example shows to load an image from external location, it does not demonstrate how this image has been cached and will be reused.
Take a look at the displaying in cells section
URLCachableViewDelegate
is explained in the delegate events section
ResourceCacheLocation
is explained in the cache location section
public init(delegate: URLCachableViewDelegate?,
sourceURLString: String,
cacheLocation: ResourceCacheLocation = .inMemory)
// Example
let urlString = ...
let cacheLocation: ResourceCacheLocation = .inMemory
let imageView = URLImageView(delegate: nil, sourceURLString: urlString, cacheLocation: cacheLocation)
public init(delegate: URLCachableViewDelegate?, cacheLocation: ResourceCacheLocation = .inMemory)
public init(frame: CGRect, cacheLocation: ResourceCacheLocation)