ImageLoader

public protocol ImageLoader

Represents a type that loads an image for an image view with a url.

  • The image placeholder

    By default, this returns an image named “img_placeholder” from the CheetahLoyaltyUI Assets.

    Declaration

    Swift

    static var imagePlaceholder: UIImage? { get }
  • loadImage(for:with:completion:) Default implementation

    Load an image for the given image view with the given url string.

    The default implementation of this method tries to create a URL from the given url string and then calls loadImage(for: UIImageView, with: URL). If the given url string is not a valid url, this will do nothing and not also execute the completion closure.

    Default Implementation

    Undocumented

    Declaration

    Swift

    func loadImage(for imageView: UIImageView,
                   with urlString: String,
                   completion: ImageLoaderCompletion?)

    Parameters

    imageView

    The image view to set the loaded image into.

    urlString

    The absolute string of the url of the image.

    completion

    A closure to be executed upon completion of loading the image.

  • Load an image for the given image view with the given url.

    The default implementation of this method sets the image of the given image view with the image placeholder.

    Declaration

    Swift

    func loadImage(for imageView: UIImageView,
                   with url: URL,
                   completion: ImageLoaderCompletion?)

    Parameters

    imageView

    The image view to set the loaded image into.

    url

    The url of the image.

    completion

    A closure to be executed upon completion of loading the image.