RSDImageWrapper

public struct RSDImageWrapper

RSDImageWrapper vends an image. It does not handle image caching. If your app using a custom image caching, then you will need to use the shared delegate to implement this. The image wrapper is designed to allow coding of images using an imageName property as a key for accessing the image.

  • The name of the image to be fetched.

    Declaration

    Swift

    public let imageName: String
  • The size of the image.

    Declaration

    Swift

    public let size: CGSize
  • The bundle for the image.

    Declaration

    Swift

    public var bundle: Bundle?
  • The sharedDelegate is a singleton delegate that can be used to customize the rules for fetching an image using the RSDImageWrapper. If defined and attached to the RSDImageWrapper using the this property, then the image wrapper will ask the delegate for the appropriate image.

    Declaration

    Swift

    public static var sharedDelegate: RSDImageWrapperDelegate?
  • Initialize the wrapper with a given image name.

    Throws

    RSDValidationError.invalidImageName if the wrapper cannot convert the imageName to an image. This error will only be thrown if there is not a sharedDelegate. In that case, this initializer will check that the image is either included in the main bundle or in the bundle returned by a call to RSDResourceConfig.resourceBundle().

    Declaration

    Swift

    public init?(imageName: String, bundle: Bundle? = nil) throws

    Parameters

    imageName

    The name of the image to be fetched.

  • Fetch the image.

    Declaration

    Swift

    public func fetchImage(for size: CGSize, callback: @escaping ((String?, RSDImage?) -> Void))

    Parameters

    size

    The size of the image to return.

    callback

    The callback with the image, run on the main thread.

  • Declaration

    Swift

    public func embeddedImage() -> RSDImage?
  • The unique identifier for the image.

    Declaration

    Swift

    public var imageIdentifier: String { get }
  • The placement type for the image. This is nil for an RSDImageWrapper.

    Declaration

    Swift

    public var placementType: RSDImagePlacementType? { get }
  • Declaration

    Swift

    public typealias RawValue = String
  • The imageName is used to represent the image wrapper.

    Declaration

    Swift

    public var rawValue: String { get }
  • Required initializer for conformance to RawRepresentable. This will return nil if the image is not valid.

    Declaration

    Swift

    public init?(rawValue: String)
  • Declaration

    Swift

    public static func == (lhs: RSDImageWrapper, rhs: RSDImageWrapper) -> Bool
  • Required initializer for conformance to ExpressibleByStringLiteral.

    Declaration

    Swift

    public init(stringLiteral value: String)

    Parameters

    stringLiteral

    The imageName for this image wrapper.

  • Required initializer for conformance to Decodable.

    Throws

    DecodingError if the value is not a String or RSDValidationError.invalidImageName if the wrapper cannot convert the string to an image.

    Declaration

    Swift

    public init(from decoder: Decoder) throws

    Parameters

    decoder

    The decoder to use to decode this value. This is expected to have a single value container.