<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSMenuItem/init(title:action:keyEquivalent:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSMenuItem(im)initWithTitle:action:keyEquivalent:"
  },
  "title" : "init(title:action:keyEquivalent:)"
}
-->

# init(title:action:keyEquivalent:)

Returns an initialized instance of `NSMenuItem`.

```
init(title string: String, action selector: Selector?, keyEquivalent charCode: String)
```

## Parameters

`string`

The title of the menu item. This value must not be `nil` (if there is no title, specify an empty `NSString`).

`selector`

The action selector to be associated with the menu item. This value must be a valid selector or `NULL`.

`charCode`

A string representing a keyboard key to be used as the key equivalent. This value must not be `nil` (if there is no key equivalent, specify an empty `NSString`).

## Return Value

An instance of `NSMenuItem`.

## Discussion

For instances of the `NSMenuItem` class, the default initial state is `NSOffState`, the default on-state image is a check mark, and the default mixed-state image is a dash.

## See Also

[`NSMenuItem`](/documentation/AppKit/NSMenuItem)

A command item in an app menu.



---

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)