---
title: "color(withKey:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nscolorlist/color(withkey:)"
---

# color(withKey:)

Returns the color object associated with the specified key.

## Declaration

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

## Parameters

- `key`: The key for which to retrieve the color.

## Return Value

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

## See Also

### Managing Colors By Key

- [allKeys](appkit/nscolorlist/allkeys.md)
- [insertColor(_:key:at:)](appkit/nscolorlist/insertcolor(_:key:at:).md)
- [removeColor(withKey:)](appkit/nscolorlist/removecolor(withkey:).md)
- [setColor(_:forKey:)](appkit/nscolorlist/setcolor(_:forkey:).md)
