---
title: numberOfComponents
framework: appkit
role: symbol
role_heading: Instance Property
path: appkit/nscolor/numberofcomponents
---

# numberOfComponents

The number of components in the color.

## Declaration

```swift
var numberOfComponents: Int { get }
```

## Discussion

Discussion This property reflects the number of floating-point component values in the color and includes the alpha component. If the color object does not have any floating-point component values, accessing this property raises an exception.

## See Also

### Related Documentation

- [colorSpace](appkit/nscolor/colorspace.md)

### Retrieving component values from color objects

- [getCyan(_:magenta:yellow:black:alpha:)](appkit/nscolor/getcyan(_:magenta:yellow:black:alpha:).md)
- [getHue(_:saturation:brightness:alpha:)](appkit/nscolor/gethue(_:saturation:brightness:alpha:).md)
- [getRed(_:green:blue:alpha:)](appkit/nscolor/getred(_:green:blue:alpha:).md)
- [getWhite(_:alpha:)](appkit/nscolor/getwhite(_:alpha:).md)
- [getComponents(_:)](appkit/nscolor/getcomponents(_:).md)
