<!--
{
  "availability" : [
    "macOS: 11.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSTableViewDiffableDataSourceReference/init(tableView:cellProvider:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSTableViewDiffableDataSource(im)initWithTableView:cellProvider:"
  },
  "title" : "init(tableView:cellProvider:)"
}
-->

# init(tableView:cellProvider:)

Creates a diffable data source with the specified cell provider, and connects it to the specified table view.

```
init(tableView: NSTableView, cellProvider: @escaping NSTableViewDiffableDataSourceReferenceCellProvider)
```

## Parameters

`tableView`

The initialized table view object to connect to the diffable data source.

`cellProvider`

A closure that creates and returns each of the cells for the table view from the data the diffable data source provides. This replaces the [`tableView(_:viewFor:row:)`](/documentation/AppKit/NSTableViewDelegate/tableView(_:viewFor:row:)) delegate method.

---

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)