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

# setState(_:atRow:column:)

Sets the state of the cell at specified location.

```
func setState(_ value: Int, atRow row: Int, column col: Int)
```

## Parameters

`value`

The value to assign to the cell.

`row`

The row in which the cell is located.

`col`

The column in which the cell is located.

## Discussion

For radio-mode matrices, if `value` is nonzero the specified cell is selected before its state is set to `value`. If `value` is 0 and the receiver is a radio-mode matrix, the currently selected cell is deselected (providing that empty selection is allowed).

This method redraws the affected cell.

## See Also

[`var state: NSControl.StateValue`](/documentation/AppKit/NSCell/state)

The cell’s current state.

[`func selectCell(atRow: Int, column: Int)`](/documentation/AppKit/NSMatrix/selectCell(atRow:column:))

Selects the cell at the specified row and column within the receiver.

[`var allowsEmptySelection: Bool`](/documentation/AppKit/NSMatrix/allowsEmptySelection)

A Boolean that indicates whether a radio-mode matrix supports an empty selection.



---

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)