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

# color(withKey:)

Returns the color object associated with the specified key.

```
func color(withKey key: NSColor.Name) -> NSColor?
```

## Parameters

`key`

The key for which to retrieve the color.

## Return Value

The color associated with the given key or `nil` if there is none.

---

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)