---
title: "setTitle(_:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nspopupbuttoncell/settitle(_:)"
---

# setTitle(_:)

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

## Declaration

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

## Parameters

- `string`: The string to display.

## Discussion

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

### Related Documentation

- [init(textCell:pullsDown:)](appkit/nspopupbuttoncell/init(textcell:pullsdown:).md)

### Dealing with selection

- [select(_:)](appkit/nspopupbuttoncell/select(_:).md)
- [selectItem(at:)](appkit/nspopupbuttoncell/selectitem(at:).md)
- [selectItem(withTag:)](appkit/nspopupbuttoncell/selectitem(withtag:).md)
- [selectItem(withTitle:)](appkit/nspopupbuttoncell/selectitem(withtitle:).md)
- [selectedItem](appkit/nspopupbuttoncell/selecteditem.md)
- [indexOfSelectedItem](appkit/nspopupbuttoncell/indexofselecteditem.md)
- [synchronizeTitleAndSelectedItem()](appkit/nspopupbuttoncell/synchronizetitleandselecteditem().md)
