---
title: colorSpace
framework: appkit
role: symbol
role_heading: Instance Property
path: appkit/nscolor/colorspace
---

# colorSpace

The color space associated with the color.

## Declaration

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

## Discussion

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-based object before calling this method. It is safe to access this property for color objects created with the color space names calibratedWhite, NSCalibratedBlackColorSpace, calibratedRGB, deviceWhite, NSDeviceBlackColorSpace, deviceRGB, deviceCMYK, or custom—or with the NSColorSpace class methods corresponding to these names.

## See Also

### Related Documentation

- [getComponents(_:)](appkit/nscolor/getcomponents(_:).md)
- [numberOfComponents](appkit/nscolor/numberofcomponents.md)

### Working with the color space

- [type](appkit/nscolor/type.md)
- [usingType(_:)](appkit/nscolor/usingtype(_:).md)
- [NSColor.ColorType](appkit/nscolor/colortype.md)
- [NSColorSpaceName](appkit/nscolorspacename.md)
