<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSColor/colorSpace",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSColor(py)colorSpace"
  },
  "title" : "colorSpace"
}
-->

# colorSpace

The color space associated with the color.

```
var colorSpace: NSColorSpace { get }
```

## Discussion

Access this property only for colors that have an associated color space—specifically, colors not created by name or using a pattern image. Accessing it for other color types raises an exception. If you are unsure about a color object, convert it to an equivalent [`NSColorSpace`](/documentation/AppKit/NSColorSpace)-based object before calling this method.

It is safe to access this property for color objects created with the color space names [`calibratedWhite`](/documentation/AppKit/NSColorSpaceName/calibratedWhite), [`NSCalibratedBlackColorSpace`](/documentation/AppKit/NSCalibratedBlackColorSpace), [`calibratedRGB`](/documentation/AppKit/NSColorSpaceName/calibratedRGB), [`deviceWhite`](/documentation/AppKit/NSColorSpaceName/deviceWhite), [`NSDeviceBlackColorSpace`](/documentation/AppKit/NSDeviceBlackColorSpace), [`deviceRGB`](/documentation/AppKit/NSColorSpaceName/deviceRGB), [`deviceCMYK`](/documentation/AppKit/NSColorSpaceName/deviceCMYK), or [`custom`](/documentation/AppKit/NSColorSpaceName/custom)—or with the [`NSColorSpace`](/documentation/AppKit/NSColorSpace) class methods corresponding to these names.

## See Also

[`-  getComponents:`](/documentation/AppKit/NSColor/getComponents(_:))

Returns the components of the color as an array.

[`numberOfComponents`](/documentation/AppKit/NSColor/numberOfComponents)

The number of components in the color.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)