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

# selectCell(withTag:)

Selects the last cell with the given tag.

```
func selectCell(withTag tag: Int) -> Bool
```

## Parameters

`tag`

The tag of the cell to select.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> if the receiver contains a cell whose tag matches `anInt`, or <doc://com.apple.documentation/documentation/Swift/false> if no such cell exists

## Discussion

If the matrix has at least one cell whose tag is equal to `anInt`, the last cell (when viewing the matrix as a row-ordered array) is selected. If the specified cell is an editable text cell, its text is selected.

## See Also

[`-  cellWithTag:`](/documentation/AppKit/NSMatrix/cell(withTag:))

Searches the receiver and returns the last cell matching the specified tag.

[`-  selectCell:`](/documentation/AppKit/NSControl/selectCell(_:))

Selects the specified cell and redraws the control as needed.



---

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)