The NSColorSpace class enables the creation of objects representing custom color spaces. You can make custom color spaces from ColorSync profiles or from ICC profiles. NSColorSpace also has factory methods that return objects representing the system color spaces.


You can use the init(colorSpace:components:count:) method of the NSColor class to create color objects using custom NSColorSpace objects. You can also send the usingColorSpace(_:) message to an NSColor object to convert it between two color spaces, either of which may be a custom color space.


Getting the Color Spaces Available On the System

class func availableColorSpaces(with: NSColorSpaceModel)

Returns the list of color spaces available on the system that are displayed in the color panel, in the order they are displayed in the color panel.

Initializing a Custom NSColorSpace Object

init?(cgColorSpace: CGColorSpace)

Initializes and returns an NSColorSpace object initialized from a Core Graphics color-space object.

init?(colorSyncProfile: UnsafeMutableRawPointer)

Initializes and returns an NSColorSpace object given a ColorSync profile.

init?(iccProfileData: Data)

Initializes and returns an NSColorSpace object given an ICC profile.

Accessing Color-Space Data and Attributes

var cgColorSpace: CGColorSpace?

The Core Graphics color-space object that represents a color space equivalent to the receiver’s.

var colorSpaceModel: NSColorSpaceModel

The model on which the color space of the receiver is based.

var colorSyncProfile: UnsafeMutableRawPointer?

The ColorSync profile from which the receiver was created.

var iccProfileData: Data?

The ICC profile data from which the receiver was created.

var localizedName: String?

The localized name of the receiver

var numberOfColorComponents: Int

The number of components (excluding alpha) the receiver supports or zero if the receiver is not based on float components.



The type of the color-space mode constants listed in Color Space Models.

Color Space Models

Identify the abstract model on which an NSColorSpace object is based.


Inherits From