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

# insertColumn(_:with:)

Inserts a new column of cells before the specified column, using the given cells.

```
func insertColumn(_ column: Int, with newCells: [NSCell]?)
```

## Parameters

`column`

The column at which to insert the new cells.

`newCells`

An array of objects to use to fill the new column, starting with the object at index 0. Each object should be an instance of [`NSCell`](/documentation/AppKit/NSCell) or one of its subclasses (usually [`NSActionCell`](/documentation/AppKit/NSActionCell)).

## Discussion

If `column` is greater than the number of columns in the receiver, enough columns are created to expand the receiver to be `column` columns wide. `newCells` should either be empty or contain a sufficient number of cells to fill each new column. If `newCells` is `nil` or an array with no elements, the call is equivalent to calling [`insertColumn(_:)`](/documentation/AppKit/NSMatrix/insertColumn(_:)). Extra cells are ignored, unless the matrix is empty. In that case, a matrix is created with one column and enough rows for all the elements of `newCells`.

This method redraws the receiver. Your code may need to send [`sizeToCells()`](/documentation/AppKit/NSMatrix/sizeToCells()) after sending this method to resize the receiver to fit the newly added cells.

---

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)