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

# addItem(withTitle:action:keyEquivalent:)

Creates a new menu item and adds it to the end of the menu.

```
func addItem(withTitle string: String, action selector: Selector?, keyEquivalent charCode: String) -> NSMenuItem
```

## Parameters

`string`

A string to be made the title of the menu item.

`selector`

The action-message selector to assign to the menu item.

`charCode`

A string identifying the key to use as a key equivalent for the menu item. If you do not want the menu item to have a key equivalent, `keyEquiv` should be an empty string (`@""`) and not `nil`.

## Return Value

The created menu item (an object conforming to the NSMenuItem protocol) or `nil` if the object couldn’t be created.

## 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)