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

# addItem(withTitle:)

Adds an item with the specified title to the end of the menu.

```
func addItem(withTitle title: String)
```

## Parameters

`title`

The title of the new menu item. If an item with the same title already exists in the menu, the existing item is removed and the new one is added.

## Discussion

The menu item uses the pop-up button’s default action and target, but you can change these using the setAction: and setTarget: methods of the corresponding [`NSMenuItem`](/documentation/AppKit/NSMenuItem) object.

Because this method searches for duplicate items, it should not be used if you are adding an item to an already populated menu with more than a few hundred items. In a situation like this, add items directly to the button’s menu instead.

---

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)