---
title: "numberOfItems(in:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nscomboboxdatasource/numberofitems(in:)"
---

# numberOfItems(in:)

Returns the number of items that the data source manages for the combo box.

## Declaration

```swift
@MainActor optional func numberOfItems(in comboBox: NSComboBox) -> Int
```

## Parameters

- `comboBox`: The combo box.

## Return Value

Return Value The number of items that the data source object manages for the specified combo box.

## Discussion

Discussion An NSComboBox object uses this method to determine how many items it should display in its pop-up list. important: While this method is marked as @optional in the protocol, you must implement this method if you are not providing the data for the combo box using Cocoa bindings.

## See Also

### Instance Methods

- [comboBox(_:completedString:)](appkit/nscomboboxdatasource/combobox(_:completedstring:).md)
- [comboBox(_:indexOfItemWithStringValue:)](appkit/nscomboboxdatasource/combobox(_:indexofitemwithstringvalue:).md)
- [comboBox(_:objectValueForItemAt:)](appkit/nscomboboxdatasource/combobox(_:objectvalueforitemat:).md)
