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

# renewRows(_:columns:)

Changes the number of rows and columns in the receiver.

```
func renewRows(_ newRows: Int, columns newCols: Int)
```

## Parameters

`newRows`

The new number of rows in the matrix.

`newCols`

The new number of columns in the matrix.

## Discussion

This method uses the same cells as before, creating new cells only if the new size is larger; it never frees cells. It doesn’t redisplay the receiver. Your code should normally send [`sizeToCells()`](/documentation/AppKit/NSMatrix/sizeToCells()) after invoking this method to resize the receiver so it fits the changed cell arrangement. This method deselects all cells in the receiver.

---

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)