---
title: "selectItem(withTag:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nspopupbutton/selectitem(withtag:)"
---

# selectItem(withTag:)

Selects the menu item with the specified tag.

## Declaration

```swift
func selectItem(withTag tag: Int) -> Bool
```

## Parameters

- `tag`: The tag of the item you want to select.

## Return Value

Return Value true if the item was successfully selected; otherwise, false.

## Discussion

Discussion If no item with the specified tag is found, this method returns false and leaves the menu state unchanged. You typically assign tags to menu items from Interface Builder, but you can also assign them programmatically using the setTag: method of NSMenuItem.

## See Also

### Related Documentation

- [indexOfItem(withTag:)](appkit/nspopupbutton/indexofitem(withtag:).md)

### Setting the current selection

- [select(_:)](appkit/nspopupbutton/select(_:).md)
- [selectItem(at:)](appkit/nspopupbutton/selectitem(at:).md)
- [selectItem(withTitle:)](appkit/nspopupbutton/selectitem(withtitle:).md)
