Data
Extends Data
to support the Action Data controls and adds convenience methods for working with data properties in a Codable
, Encodable
or Decodable
class.
Examples:
// Assign data from an image in macOS
let imageData: Data ~= NSImage(named: "Background.png")
-
Sets the
Data
instance from the givenNSImage
instance.Examples:
// Assign data from an image in macOS let imageData: Data ~= NSImage(named: "Background.png")
Declaration
Swift
public static func ~= ( left: inout Data, right: NSImage)
-
Attempts to create a
NSImage
from the data stored in the currentData
instance. Returns the Image if it can be created else returnsnil
.Examples:
// Assign data from an macOS let imageData: Data ~= NSImage(named: "Background.png") if let image = imageData.nsImage { ... }
Declaration
Swift
public var nsImage: NSImage?