<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSComboBoxDataSource/numberOfItems(in:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(pl)NSComboBoxDataSource(im)numberOfItemsInComboBox:"
  },
  "title" : "numberOfItems(in:)"
}
-->

# numberOfItems(in:)

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

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

## Parameters

`comboBox`

The combo box.

## Return Value

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

## 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.

---

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)