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

# performActionForItem(at:)

Causes the application to send the action message of a specified menu item to its target.

```
func performActionForItem(at index: Int)
```

## Parameters

`index`

The integer index of a menu item.

## Discussion

If a target is not specified, the message is sent to the first responder. As a side effect, this method posts [`willSendActionNotification`](/documentation/AppKit/NSMenu/willSendActionNotification) and [`didSendActionNotification`](/documentation/AppKit/NSMenu/didSendActionNotification).

In macOS 10.6 and later the `performActionForItemAtIndex:` no longer triggers menu validation. This is because validation is typically done during menu tracking or key equivalent matching, so the subsequent `performActionForItemAtIndex:` validation was redundant. To trigger validation explicitly, use invoke the [`update()`](/documentation/AppKit/NSMenu/update()) method.

In OS X v10.6 `performActionForItemAtIndex:`, when called, now triggers highlighting in the menu bar. It also sends out appropriate accessibility notifications indicating the item was selected.

## See Also

[`performKeyEquivalent(with:)`](/documentation/AppKit/NSMenu/performKeyEquivalent(with:))

Performs the action for the menu item that corresponds to the given key equivalent.



---

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)