---
title: addColumn()
framework: appkit
role: symbol
role_heading: Instance Method
path: appkit/nsmatrix/addcolumn()
---

# addColumn()

Adds a new column of cells to the right of the last column.

## Declaration

```swift
func addColumn()
```

## Discussion

Discussion This method raises an NSRangeException if there are 0 rows or 0 columns. This method creates new cells as needed with makeCell(atRow:column:). Use renewRows(_:columns:) to add new cells to an empty matrix. If the number of rows or columns in the receiver has been changed with renewRows(_:columns:), new cells are created only if they are needed. This fact allows you to grow and shrink an NSMatrix without repeatedly creating and freeing the cells. This method redraws the receiver. Your code may need to send sizeToCells() after sending this method to resize the receiver to fit the newly added cells.

## See Also

### Related Documentation

- [prototype](appkit/nsmatrix/prototype.md)
- [cellClass](appkit/nsmatrix/cellclass.md)

### Laying Out the Cells of the Matrix

- [addColumn(with:)](appkit/nsmatrix/addcolumn(with:).md)
- [addRow()](appkit/nsmatrix/addrow().md)
- [addRow(with:)](appkit/nsmatrix/addrow(with:).md)
- [cellFrame(atRow:column:)](appkit/nsmatrix/cellframe(atrow:column:).md)
- [cellSize](appkit/nsmatrix/cellsize.md)
- [getNumberOfRows(_:columns:)](appkit/nsmatrix/getnumberofrows(_:columns:).md)
- [insertColumn(_:)](appkit/nsmatrix/insertcolumn(_:).md)
- [insertColumn(_:with:)](appkit/nsmatrix/insertcolumn(_:with:).md)
- [insertRow(_:)](appkit/nsmatrix/insertrow(_:).md)
- [insertRow(_:with:)](appkit/nsmatrix/insertrow(_:with:).md)
- [intercellSpacing](appkit/nsmatrix/intercellspacing.md)
- [makeCell(atRow:column:)](appkit/nsmatrix/makecell(atrow:column:).md)
- [numberOfColumns](appkit/nsmatrix/numberofcolumns.md)
- [numberOfRows](appkit/nsmatrix/numberofrows.md)
- [putCell(_:atRow:column:)](appkit/nsmatrix/putcell(_:atrow:column:).md)
