Instance Method

setColor(_:forKey:)

Associates the specified NSColor object with the specified key.

Declaration

func setColor(_ color: NSColor, forKey key: NSColor.Name)

Parameters

color

The color to associate with the given key.

key

The key.

Discussion

If the list already contains key, this method sets the corresponding color to color; otherwise, it inserts color at the end of the list by invoking insertColor(_:key:at:).

See Also

Managing Colors By Key

var allKeys: [NSColor.Name]

An array of the keys by which the NSColor objects are stored in the receiver.

func color(withKey: NSColor.Name) -> NSColor?

Returns the NSColor object associated with the given key.

func insertColor(NSColor, key: NSColor.Name, at: Int)

Inserts the specified color at the specified location in the receiver.

func removeColor(withKey: NSColor.Name)

Removes the color associated with the specified key from the receiver.