---
title: "insertColor(_:key:at:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nscolorlist/insertcolor(_:key:at:)"
---

# insertColor(_:key:at:)

Inserts the specified color at the specified location in the color list.

## Declaration

```swift
func insertColor(_ color: NSColor, key: NSColor.Name, at loc: Int)
```

## Parameters

- `color`: The color to add to the color list.
- `key`: The key with which to associate the color.
- `loc`: The location in the color list at which to place the specified color. Locations are numbered starting with 0.

## Discussion

Discussion If the list already contains a color with the same key at a different location, it’s removed from the old location. This method posts didChangeNotification to the default notification center. It raises NSColorListNotEditableException if the color list isn’t editable.

## See Also

### Managing Colors By Key

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