---
title: "init(frame:mode:cellClass:numberOfRows:numberOfColumns:)"
framework: appkit
role: symbol
role_heading: Initializer
path: "appkit/nsmatrix/init(frame:mode:cellclass:numberofrows:numberofcolumns:)"
---

# init(frame:mode:cellClass:numberOfRows:numberOfColumns:)

Initializes and returns a newly allocated matrix of the specified size using cells of the given class.

## Declaration

```swift
init(frame frameRect: NSRect, mode: NSMatrix.Mode, cellClass factoryId: AnyClass?, numberOfRows rowsHigh: Int, numberOfColumns colsWide: Int)
```

## Parameters

- `frameRect`: The matrix’s frame.
- `mode`: The tracking mode for the matrix; this can be one of the modes described in doc://com.apple.appkit/documentation/AppKit/NSMatrix/Mode-swift.enum.
- `factoryId`: The class to use for any cells that the matrix creates and uses. This can be obtained by sending a class message to the desired subclass of doc://com.apple.appkit/documentation/AppKit/NSCell.
- `rowsHigh`: The number of rows in the matrix.
- `colsWide`: The number of columns in the matrix.

## Return Value

Return Value The initialized instance of NSMatrix.

## Discussion

Discussion This method is the designated initializer for matrices that add cells by creating instances of an NSCell subclass.

## See Also

### Initializing an NSMatrix Object

- [init(frame:)](appkit/nsmatrix/init(frame:).md)
- [init(frame:mode:prototype:numberOfRows:numberOfColumns:)](appkit/nsmatrix/init(frame:mode:prototype:numberofrows:numberofcolumns:).md)
