Class

NSColorList

An ordered list of NSColor objects, identified by keys.

Overview

Instances of NSColorList, or more simply color lists, are used to manage named lists of NSColor instances. The NSColorPanel list mode color picker uses instances of NSColorList to represent any lists of colors that come with the system, as well as any lists created by the user. An application can use color list to manage document-specific color lists.

Topics

Initializing an NSColorList Object

init(name: NSColorList.Name)

Initializes and returns the receiver, registering it under the given name if it isn’t in use already.

init?(name: NSColorList.Name, fromFile: String?)

Initializes and returns the receiver, registering it under the given name if it isn’t in use already.

Getting Color Lists

class var availableColorLists: [NSColorList]

Returns an array of all color lists found in the standard color list directories.

init?(named: NSColorList.Name)

Searches the array that’s returned by availableColorLists and returns the color list with the given name.

Getting Color List Properties

var name: NSColorList.Name?

The name of the receiver.

var isEditable: Bool

A Boolean value indicating whether the receiver can be modified.

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)

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.

func setColor(NSColor, forKey: NSColor.Name)

Associates the specified NSColor object with the specified key.

Writing and Removing Color-List Files

func removeFile()

Removes the file from which the list was created, if the file is in a standard search path and owned by the user.

func write(toFile: String?)

Saves the receiver to a file at the specified path.

Instance Methods

Relationships

Inherits From

See Also

Colors

class NSColor

An object that stores color data and sometimes opacity (alpha value).

class NSColorSpace

An object that represents a custom color spaces.