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

# dataSource

The object that provides the data displayed by the table view.

```
weak var dataSource: (any NSTableViewDataSource)? { get set }
```

## Discussion

The data source for the table view must implement the appropriate methods of the [`NSTableViewDataSource`](/documentation/AppKit/NSTableViewDataSource) protocol. For more information, see the [`NSTableViewDataSource`](/documentation/AppKit/NSTableViewDataSource) `protocol` specification. Note that in versions of macOS prior to v10.12, the table view did not retain the data source in a managed memory environment.

Setting the data source invokes [`tile()`](/documentation/AppKit/NSTableView/tile()).

If the delegate doesn’t respond to either [`numberOfRows(in:)`](/documentation/AppKit/NSTableViewDataSource/numberOfRows(in:)) or [`tableView(_:objectValueFor:row:)`](/documentation/AppKit/NSTableViewDataSource/tableView(_:objectValueFor:row:)), <doc://com.apple.documentation/documentation/Foundation/NSExceptionName/internalInconsistencyException> may be raised.

---

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)