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

# getRed(_:green:blue:alpha:)

Returns the color object’s RGB component and opacity values in the respective arguments.

```
func getRed(_ red: UnsafeMutablePointer<CGFloat>?, green: UnsafeMutablePointer<CGFloat>?, blue: UnsafeMutablePointer<CGFloat>?, alpha: UnsafeMutablePointer<CGFloat>?)
```

## Parameters

`red`

Upon return, contains the red component of the color object.

`green`

Upon return, contains the green component of the color object.

`blue`

Upon return, contains the blue component of the color object.

`alpha`

Upon return, contains the opacity value of the color object.

## Discussion

If `NULL` is passed in as an argument, the method doesn’t set that value. This method works only with objects representing colors in the [`calibratedRGB`](/documentation/AppKit/NSColorSpaceName/calibratedRGB) or [`deviceRGB`](/documentation/AppKit/NSColorSpaceName/deviceRGB) color space. Sending it to other objects raises an exception.

## See Also

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

The blue component value of the color.

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

The red component value of the color.

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

The alpha (opacity) component value of the color.

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

The green component value of 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)