---
title: "init(title:action:keyEquivalent:)"
framework: appkit
role: symbol
role_heading: Initializer
path: "appkit/nsmenuitem/init(title:action:keyequivalent:)"
---

# init(title:action:keyEquivalent:)

Returns an initialized instance of NSMenuItem.

## Declaration

```swift
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

Return Value An instance of NSMenuItem.

## Discussion

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

### Related Documentation

- [NSMenuItem](appkit/nsmenuitem.md)

### Creating a menu item

- [init(coder:)](appkit/nsmenuitem/init(coder:).md)
