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

# sendAction(_:to:forAllCells:)

Iterates through the cells in the receiver, sending the specified selector to an object for each cell.

```
func sendAction(_ selector: Selector, to object: Any, forAllCells flag: Bool)
```

## Parameters

`selector`

The selector to send to the object for each cell. This must represent a method that takes a single argument: the id of the current cell in the iteration. `aSelector`’s return value must be a BOOL. If `aSelector` returns <doc://com.apple.documentation/documentation/Swift/false> for any cell, [`NSMatrix`](/documentation/AppKit/NSMatrix) terminates immediately, without sending the message for the remaining cells. If it returns <doc://com.apple.documentation/documentation/Swift/true>, [`NSMatrix`](/documentation/AppKit/NSMatrix) proceeds to the next cell.

`object`

The object that is sent the selector for each cell in the matrix.

`flag`

<doc://com.apple.documentation/documentation/Swift/true> if the method should iterate through all cells in the matrix; <doc://com.apple.documentation/documentation/Swift/false> if it should iterate through just the selected cells in the matrix.

## Discussion

Iteration begins with the cell in the upper-left corner of the receiver, proceeding through the appropriate entries in the first row, then on to the next.

This method is not invoked to send action messages to target objects in response to mouse-down events in the receiver. Instead, you can invoke it if you want to have multiple cells in an [`NSMatrix`](/documentation/AppKit/NSMatrix) interact with an object. For example, you could use it to verify the titles in a list of items or to enable a series of radio buttons based on their purpose in relation to `anObject`.

---

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)