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

# setTitle(_:)

Sets the string displayed in the receiver when the user isn’t pressing the mouse button.

```
func setTitle(_ string: String?)
```

## Parameters

`string`

The string to display.

## Discussion

For pull-down menus that get their titles from a menu item, this method simply sets the pop-up button cell’s menu item to the first item in the menu. For pop-up menus, if a menu item whose title matches `aString` exists, this method makes that menu item the current selection; otherwise, it creates a new menu item with the title `aString`, adds it to the pop-up menu, and selects it.

## See Also

[`init(textCell:pullsDown:)`](/documentation/AppKit/NSPopUpButtonCell/init(textCell:pullsDown:))

Returns an `NSPopUpButtonCell` object initialized with the specified title.



---

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)