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

# NSComboBox

A view that displays a list of values in a pop-up menu where the user selects a value or types in a custom value.

```
class NSComboBox
```

## Overview

A combo box combines the behavior of an [`NSTextField`](/documentation/AppKit/NSTextField) object with an [`NSPopUpButton`](/documentation/AppKit/NSPopUpButton) object. A combo box displays a list of values from a pop-up list, but also provides a means for users to type in custom values. For example, here’s a combo box in its initial state.

![A screenshot of a collapsed combo box.](images/com.apple.appkit/media-4305420@2x.png)

Clicking in the text portion of the control allows the user to edit the current value. When the user clicks the down arrow at the right side of the text field, the pop-up list appears.

![A screenshot of an expanded combo box. The first item in the list, Item A, is selected. The remaining three items are expanded and listed below.](images/com.apple.appkit/media-4305419@2x.png)

The [`NSComboBox`](/documentation/AppKit/NSComboBox) class uses [`NSComboBoxCell`](/documentation/AppKit/NSComboBoxCell) to implement its user interface.

Also see the [`NSComboBoxDataSource`](/documentation/AppKit/NSComboBoxDataSource) protocol, which declares the methods that [`NSComboBox`](/documentation/AppKit/NSComboBox) uses to access the contents of its data source object.

## Topics

### Setting Display Attributes

[`hasVerticalScroller`](/documentation/AppKit/NSComboBox/hasVerticalScroller)

A Boolean value indicating whether the combo box has a vertical scroller.

[`intercellSpacing`](/documentation/AppKit/NSComboBox/intercellSpacing)

The horizontal and vertical spacing between cells in the pop-up list.

[`isButtonBordered`](/documentation/AppKit/NSComboBox/isButtonBordered)

A Boolean value indicating whether the combo box displays a border.

[`itemHeight`](/documentation/AppKit/NSComboBox/itemHeight)

The height of each item in the pop-up list.

[`numberOfVisibleItems`](/documentation/AppKit/NSComboBox/numberOfVisibleItems)

The maximum number of visible items to display in the pop-up list at one time.

### Setting a Data Source

[`dataSource`](/documentation/AppKit/NSComboBox/dataSource)

The object that provides the item data for the combo box.

[`usesDataSource`](/documentation/AppKit/NSComboBox/usesDataSource)

A Boolean value indicating whether the combo box retrieves its items from a data source object.

### Configuring the Combo Box Items

[`addItems(withObjectValues:)`](/documentation/AppKit/NSComboBox/addItems(withObjectValues:))

Adds multiple objects to the end of the receiver’s internal item list.

[`addItem(withObjectValue:)`](/documentation/AppKit/NSComboBox/addItem(withObjectValue:))

Adds an object to the end of the receiver’s internal item list.

[`insertItem(withObjectValue:at:)`](/documentation/AppKit/NSComboBox/insertItem(withObjectValue:at:))

Inserts an object at the specified location in the receiver’s internal item list.

[`objectValues`](/documentation/AppKit/NSComboBox/objectValues)

An array of the items from the combo box’s internal list.

[`removeAllItems()`](/documentation/AppKit/NSComboBox/removeAllItems())

Removes all items from the receiver’s internal item list.

[`removeItem(at:)`](/documentation/AppKit/NSComboBox/removeItem(at:))

Removes the object at the specified location from the receiver’s internal item list.

[`removeItem(withObjectValue:)`](/documentation/AppKit/NSComboBox/removeItem(withObjectValue:))

Removes all occurrences of the given object from the receiver’s internal item list.

[`numberOfItems`](/documentation/AppKit/NSComboBox/numberOfItems)

The total number of items in the pop-up list.

### Manipulating the Displayed List

[`indexOfItem(withObjectValue:)`](/documentation/AppKit/NSComboBox/indexOfItem(withObjectValue:))

Searches the receiver’s internal item list for the specified object and returns the lowest matching index.

[`itemObjectValue(at:)`](/documentation/AppKit/NSComboBox/itemObjectValue(at:))

Returns the object located at the given index within the receiver’s internal item list.

[`noteNumberOfItemsChanged()`](/documentation/AppKit/NSComboBox/noteNumberOfItemsChanged())

Informs the receiver that the number of items in its data source has changed.

[`reloadData()`](/documentation/AppKit/NSComboBox/reloadData())

Marks the receiver as needing redisplay, so that it will reload the data for visible pop-up items and draw the new values.

[`scrollItemAtIndexToTop(_:)`](/documentation/AppKit/NSComboBox/scrollItemAtIndexToTop(_:))

Scrolls the receiver’s pop-up list vertically so that the item at the specified index is as close to the top as possible.

[`scrollItemAtIndexToVisible(_:)`](/documentation/AppKit/NSComboBox/scrollItemAtIndexToVisible(_:))

Scrolls the receiver’s pop-up list vertically so that the item at the specified index is visible.

### Manipulating the Selection

[`deselectItem(at:)`](/documentation/AppKit/NSComboBox/deselectItem(at:))

Deselects the pop-up list item at the specified index if it’s selected.

[`indexOfSelectedItem`](/documentation/AppKit/NSComboBox/indexOfSelectedItem)

The index of the last item selected from the pop-up list.

[`objectValueOfSelectedItem`](/documentation/AppKit/NSComboBox/objectValueOfSelectedItem)

The object corresponding to the last item selected from the pop-up list.

[`selectItem(at:)`](/documentation/AppKit/NSComboBox/selectItem(at:))

Selects the pop-up list row at the given index.

[`selectItem(withObjectValue:)`](/documentation/AppKit/NSComboBox/selectItem(withObjectValue:))

Selects the first pop-up list item that corresponds to the given object.

### Completing the Text Field

[`completes`](/documentation/AppKit/NSComboBox/completes)

A Boolean value indicating whether the combo box tries to complete what the user types.

### Accessing the Delegate

[`delegate`](/documentation/AppKit/NSComboBox/delegate)

Sets the receiver’s delegate.

### Notifications

[`selectionDidChangeNotification`](/documentation/AppKit/NSComboBox/selectionDidChangeNotification)

Posted after the pop-up list selection of the `NSComboBox` changes.

[`selectionIsChangingNotification`](/documentation/AppKit/NSComboBox/selectionIsChangingNotification)

Posted whenever the pop-up list selection of the `NSComboBox` is changing.

[`willDismissNotification`](/documentation/AppKit/NSComboBox/willDismissNotification)

Posted whenever the pop-up list of the `NSComboBox` is about to be dismissed.

[`willPopUpNotification`](/documentation/AppKit/NSComboBox/willPopUpNotification)

Posted whenever the pop-up list of the `NSComboBox` is going to be displayed.



---

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)