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

# numberOfRows(in:)

Returns the number of records managed for `aTableView` by the data source object.

```
@MainActor optional func numberOfRows(in tableView: NSTableView) -> Int
```

## Parameters

`tableView`

The table view that sent the message.

## Return Value

The number of rows in `aTableView`.

## Discussion

An instance of [`NSTableView`](/documentation/AppKit/NSTableView) uses this method to determine how many rows it should create and display. Your [`numberOfRows(in:)`](/documentation/AppKit/NSTableViewDataSource/numberOfRows(in:)) implementation is called very frequently, so it must be efficient.

Both view-based table views and cell-based table views must implement this method.

> Note:
> This method is mandatory unless your application is using Cocoa bindings for providing data to the table view.

## See Also

[`NSTableView`](/documentation/AppKit/NSTableView)

A set of related records, displayed in rows that represent individual records and columns that represent the attributes of those records.



---

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)