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

# selectedCells

An array containing all of the matrix’s highlighted cells plus its selected cell.

```
var selectedCells: [NSCell] { get }
```

## Discussion

See the class description for a discussion of the selected cell.

As an alternative to using [`setSelectionFrom(_:to:anchor:highlight:)`](/documentation/AppKit/NSMatrix/setSelectionFrom(_:to:anchor:highlight:)) for programmatically making discontiguous selections of cells in a matrix, you could first set the single selected cell and then set subsequent cells to be highlighted; afterwards you can access [`selectedCells`](/documentation/AppKit/NSMatrix/selectedCells) to obtain the selection of cells.

## See Also

[`isHighlighted`](/documentation/AppKit/NSCell/isHighlighted)

A Boolean value indicating whether the cell has a highlighted appearance.

[`selectedCell`](/documentation/AppKit/NSMatrix/selectedCell)

The most recently selected cell.



---

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)