Nuke Documentation

Structure Image​Request

public struct ImageRequest: CustomStringConvertible  

Represents an image request.

ImageRequest ImageRequest CustomStringConvertible CustomStringConvertible ImageRequest->CustomStringConvertible ImageRequestConvertible ImageRequestConvertible ImageRequest->ImageRequestConvertible

Nested Types

ImageRequest.Priority

The priority affecting the order in which the requests are performed.

ImageRequest.UserInfoKey

A key use in userInfo.

ImageRequest.Options

Image request options.

ImageRequest.ThumbnailOptions

Thumbnail options.

Conforms To

ImageRequestConvertible

Represents a type that can be converted to an ImageRequest.

CustomStringConvertible

Initializers

init(url:​processors:​priority:​options:​user​Info:​)

public init(url: URL?,
                processors: [ImageProcessing]? = nil,
                priority: Priority = .normal,
                options: Options = [],
                userInfo: [UserInfoKey: Any]? = nil)  

Initializes a request with the given URL.

let request = ImageRequest(
    url: URL(string: "http://..."),
    processors: [ImageProcessors.Resize(size: imageView.bounds.size)],
    priority: .high
)

Parameters

url URL?

The request URL.

processors [Image​Processing]?

Processors to be apply to the image. nil by default.

priority Priority

The priority of the request, .normal by default.

options Options

Image loading options. [] by default.

user​Info [User​Info​Key:​ Any]?

Custom info passed alongside the request. nil by default.

init(url​Request:​processors:​priority:​options:​user​Info:​)

public init(urlRequest: URLRequest,
                processors: [ImageProcessing]? = nil,
                priority: Priority = .normal,
                options: Options = [],
                userInfo: [UserInfoKey: Any]? = nil)  

Initializes a request with the given request.

let request = ImageRequest(
    url: URLRequest(url: URL(string: "http://...")),
    processors: [ImageProcessors.Resize(size: imageView.bounds.size)],
    priority: .high
)

Parameters

url​Request URLRequest

The URLRequest describing the image request.

processors [Image​Processing]?

Processors to be apply to the image. nil by default.

priority Priority

The priority of the request, .normal by default.

options Options

Image loading options. [] by default.

user​Info [User​Info​Key:​ Any]?

Custom info passed alongside the request. nil by default.

init(id:​data:​processors:​priority:​options:​user​Info:​)

@available(iOS 13.0, tvOS 13.0, watchOS 6.0, macOS 10.15, *)
    public init<P>(id: String, data: P,
                   processors: [ImageProcessing]? = nil,
                   priority: Priority = .normal,
                   options: Options = [],
                   userInfo: [UserInfoKey: Any]? = nil) where P: Publisher, P.Output == Data  

Initializes a request with the given data publisher.

For example, here is how you can use it with Photos framework (the imageDataPublisher() API is a convenience extension).

let request = ImageRequest(
    id: asset.localIdentifier,
    data: PHAssetManager.imageDataPublisher(for: asset)
)

Parameters

id String

Uniquely identifies the image data.

data P

A data publisher to be used for fetching image data.

processors [Image​Processing]?

Processors to be apply to the image. nil by default.

priority Priority

The priority of the request, .normal by default.

options Options

Image loading options. [] by default.

user​Info [User​Info​Key:​ Any]?

Custom info passed alongside the request. nil by default.

Properties

url​Request

public var urlRequest: URLRequest?  

Returns the request URLRequest.

Returns nil for publisher-based requests.

url

public var url: URL?  

Returns the request URL.

Returns nil for publisher-based requests.

image​Id

public var imageId: String?  

Returns the ID of the underlying image. For URL-based request, it's an image URL. For publisher – a custom ID.

priority

public var priority: Priority  

The relative priority of the request. The priority affects the order in which the requests are performed. .normal by default.

processors

public var processors: [ImageProcessing]  

Processor to be applied to the image. Empty by default.

options

public var options: Options  

The request options.

user​Info

public var userInfo: [UserInfoKey: Any]  

Custom info passed alongside the request.

description

public var description: String  

Methods

as​Image​Request()

public func asImageRequest() -> ImageRequest