AssetManager

@available(iOS 9.0, *)
@objcMembers
@objc(PESDKAssetManager)
open class AssetManager : NSObject

An AssetManager can be used to cache UIImage and CIImage instances and to download and cache image assets.

  • Caches an image asset for the given identifier.

    Declaration

    Swift

    open func setImageAsset(_ imageAsset: ImageAsset?, forIdentifier identifier: String)

    Parameters

    imageAsset

    The image asset to store in the cache or nil to delete an image from the cache.

    identifier

    The identifier to register this image asset for.

  • Returns the image asset for the given identifier from the cache, if available.

    Declaration

    Swift

    open func imageAsset(forIdentifier identifier: String) -> ImageAsset?

    Parameters

    identifier

    The identifier of the image asset.

    Return Value

    The cached image asset or nil.

  • This is called with false when downloading starts and again called with true when downloading ends.

    Declaration

    Swift

    open var progressClosure: ((Bool) -> Void)?
  • Retrieves multiple images from the cache and decodes them in the background. If the images are not in the cache, it downloads the images, decodes them and stores them in both a disk cache (if the passed url is not a file url) and an in-memory cache.

    Declaration

    Swift

    open func getImages(at urls: [URL], completion: @escaping (([URL: UIImage], [Error]) -> Void))

    Parameters

    urls

    A list of URLs to images.

    completion

    A completion block that is passed a list of images and errors.

  • Retrieves a single image from the cache and decodes the image in the background. If the image is not in the cache, it downloads the image, decodes it and stores it in both a disk cache (if the passed url is not a file url) and an in-memory cache.

    Declaration

    Swift

    open func getImage(at url: URL, completion: @escaping ((UIImage?, Error?) -> Void))

    Parameters

    url

    The URL of the image.

    completion

    A completion block that is passed the image on success or the error on failure.