Nuke Documentation

Function load​Image(with:​options:​into:​progress:​completion:​)

public func loadImage(
    with request: ImageRequestConvertible?,
    options: ImageLoadingOptions = ImageLoadingOptions.shared,
    into view: ImageDisplayingView,
    progress: ((_ response: ImageResponse?, _ completed: Int64, _ total: Int64) -> Void)? = nil,
    completion: ((_ result: Result<ImageResponse, ImagePipeline.Error>) -> Void)? = nil
) -> ImageTask?  

Loads an image with the given request and displays it in the view.

Before loading a new image, the view is prepared for reuse by canceling any outstanding requests and removing a previously displayed image.

If the image is stored in the memory cache, it is displayed immediately with no animations. If not, the image is loaded using an image pipeline. When the image is loading, the placeholder is displayed. When the request completes the loaded image is displayed (or failureImage in case of an error) with the selected animation.


request Image​Request​Convertible?

The image request. If nil, it's handled as a failure scenario.

options Image​Loading​Options

ImageLoadingOptions.shared by default.

view Image​Displaying​View

Nuke keeps a weak reference to the view. If the view is deallocated the associated request automatically gets canceled.

progress ((_ response:​ Image​Response?, _ completed:​ Int64, _ total:​ Int64) -> Void)?

A closure to be called periodically on the main thread when the progress is updated. nil by default.

completion ((_ result:​ Result<Image​Response, Image​Pipeline.​Error>) -> Void)?

A closure to be called on the main thread when the request is finished. Gets called synchronously if the response was found in the memory cache. nil by default.


An image task or nil if the image was found in the memory cache.