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

# NSTableViewDiffableDataSourceReference

The object you use to manage data and provide items for a table view.

```
class NSTableViewDiffableDataSourceReference<SectionIdentifierType, ItemIdentifierType> where SectionIdentifierType : AnyObject, ItemIdentifierType : AnyObject
```

## Overview> Important:
> If you’re working in a Swift codebase, always use ``doc://com.apple.appkit/documentation/AppKit/NSTableViewDiffableDataSource-c5gl`` instead of `NSTableViewDiffableDataSourceReference`.

A *diffable data source* object is a specialized type of data source that works together with your table view object. It provides the behavior you need to manage updates to your table view’s data and UI in a simple, efficient way. It also conforms to the [`NSTableViewDataSource`](/documentation/AppKit/NSTableViewDataSource) protocol.

To fill a table view with data:

1. Connect a diffable data source to your table view.
2. Implement a cell provider to configure your table view’s cells.
3. Generate the current state of the data.
4. Display the data in the UI.

To connect a diffable data source to a table view, you create the diffable data source using its [`init(tableView:cellProvider:)`](/documentation/AppKit/NSTableViewDiffableDataSourceReference/init(tableView:cellProvider:)) initializer, passing in the table view you want to associate with that data source. You also pass in a cell provider, where you configure each of your cells to determine how to display your data in the UI.

Then, you generate the current state of the data and display the data in the UI by constructing and applying a snapshot. For more information, see [`NSDiffableDataSourceSnapshotReference`](/documentation/AppKit/NSDiffableDataSourceSnapshotReference).

## Topics

### Creating a Diffable Data Source

[`init(tableView:cellProvider:)`](/documentation/AppKit/NSTableViewDiffableDataSourceReference/init(tableView:cellProvider:))

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

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

A closure that configures and returns a cell for a table view from its diffable data source.

### Creating Row and Section Views

[`rowViewProvider`](/documentation/AppKit/NSTableViewDiffableDataSourceReference/rowViewProvider)

The closure that configures and returns the table view’s row views from the diffable data source.

[`sectionHeaderViewProvider`](/documentation/AppKit/NSTableViewDiffableDataSourceReference/sectionHeaderViewProvider)

The closure that configures and returns the table view’s section header views from the diffable data source.

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

A closure that configures and returns a row view for a table view from its diffable data source.

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

A closure that configures and returns a section header view for a table view from its diffable data source.

### Identifying Items and Sections

[`itemIdentifier(forRow:)`](/documentation/AppKit/NSTableViewDiffableDataSourceReference/itemIdentifier(forRow:))

Returns an identifier for the item at the specified row in the table view.

[`row(forItemIdentifier:)`](/documentation/AppKit/NSTableViewDiffableDataSourceReference/row(forItemIdentifier:))

Returns a row for the item with the specified identifier in the table view.

[`sectionIdentifier(forRow:)`](/documentation/AppKit/NSTableViewDiffableDataSourceReference/sectionIdentifier(forRow:))

Returns the identifier of the section containing the specified row in the snapshot.

[`row(forSectionIdentifier:)`](/documentation/AppKit/NSTableViewDiffableDataSourceReference/row(forSectionIdentifier:))

Returns a row for the section with the specified identifier in the table view.

### Updating Data

[`snapshot()`](/documentation/AppKit/NSTableViewDiffableDataSourceReference/snapshot())

Returns a representation of the current state of the data in the table view.

[`applySnapshot(_:animatingDifferences:)`](/documentation/AppKit/NSTableViewDiffableDataSourceReference/applySnapshot(_:animatingDifferences:))

Updates the UI to reflect the state of the data in the specified snapshot, optionally animating the UI changes.

[`applySnapshot(_:animatingDifferences:completion:)`](/documentation/AppKit/NSTableViewDiffableDataSourceReference/applySnapshot(_:animatingDifferences:completion:))

Updates the UI to reflect the state of the data in the specified snapshot, optionally animating the UI changes and executing a completion handler.

[`defaultRowAnimation`](/documentation/AppKit/NSTableViewDiffableDataSourceReference/defaultRowAnimation)

The default animation the UI uses to show differences between rows.



---

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)