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

# cell(withTag:)

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

```
func cell(withTag tag: Int) -> NSCell?
```

## Parameters

`tag`

The tag of the cell to return.

## Return Value

The last (when viewing the matrix as a row-ordered array) [`NSCell`](/documentation/AppKit/NSCell) object that has a tag matching `anInt`, or `nil` if no such cell exists

## See Also

[`-  selectCellWithTag:`](/documentation/AppKit/NSMatrix/selectCell(withTag:))

Selects the last cell with the given tag.

[`tag`](/documentation/AppKit/NSActionCell/tag)

Returns the receiver’s tag.



---

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)