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

# setSubmenu(_:for:)

Assigns a menu to be a submenu of the menu controlled by a given menu item.

```
func setSubmenu(_ menu: NSMenu?, for item: NSMenuItem)
```

## Parameters

`menu`

A menu object that is to be a submenu of the menu.

`item`

A menu item (that is, an object conforming to the NSMenuItem protocol) that controls `aMenu`. The method sets the action of `anItem` to  [`submenuAction(_:)`](/documentation/AppKit/NSMenu/submenuAction(_:)).

## Discussion

---

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)