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

# insertColumn(_:)

Inserts a new column of cells at the specified location.

```
func insertColumn(_ column: Int)
```

## Parameters

`column`

The number of the column before which the new column is inserted. 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.

## Discussion

New cells are created if needed with [`makeCell(atRow:column:)`](/documentation/AppKit/NSMatrix/makeCell(atRow:column:)). 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.

If the number of rows or columns in the receiver has been changed with [`renewRows(_:columns:)`](/documentation/AppKit/NSMatrix/renewRows(_:columns:)), new cells are created only if they’re needed. This fact allows you to grow and shrink an [`NSMatrix`](/documentation/AppKit/NSMatrix) without repeatedly creating and freeing the 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)