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

# selectItem(withTag:)

Selects the menu item with the specified tag.

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

## Parameters

`tag`

The tag of the item you want to select.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> if the item was successfully selected; otherwise, <doc://com.apple.documentation/documentation/Swift/false>.

## Discussion

If no item with the specified tag is found, this method returns <doc://com.apple.documentation/documentation/Swift/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`](/documentation/AppKit/NSMenuItem).

---

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)