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

# menuNeedsUpdate(_:)

Invoked when a menu is about to be displayed at the start of a tracking session.

```
@MainActor optional func menuNeedsUpdate(_ menu: NSMenu)
```

## Parameters

`menu`

The menu object that is about to be displayed.

## Discussion

Using this method, the delegate can change the menu by adding, removing, or modifying menu items. If populating the menu will take a long time, implement [`numberOfItems(in:)`](/documentation/AppKit/NSMenuDelegate/numberOfItems(in:)) and [`menu(_:update:at:shouldCancel:)`](/documentation/AppKit/NSMenuDelegate/menu(_:update:at:shouldCancel:)) instead.

Menu item validation occurs after this method is called. If the menu is updated because the user pressed a command key, only the menu item with the matching command key is validated; if the menu is updated because the user opened it, then every menu item is validated.

---

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)