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

# getComponents(_:)

Returns the components of the color as an array.

```
func getComponents(_ components: UnsafeMutablePointer<CGFloat>)
```

## Parameters

`components`

An array containing the components of the color object as `float` values.

## Discussion

You can invoke this method on `NSColor` objects created from custom color spaces to get the individual floating-point components, including alpha. Raises an exception if the receiver doesn’t have floating-point components. To find out how many components are in the `components` array, use the [`numberOfComponents`](/documentation/AppKit/NSColor/numberOfComponents) property.

## See Also

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

The color space associated with 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)