<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UITableViewDiffableDataSourceReference",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UITableViewDiffableDataSource"
  },
  "title" : "UITableViewDiffableDataSourceReference"
}
-->

# UITableViewDiffableDataSourceReference

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

```
@MainActor class UITableViewDiffableDataSourceReference
```

## Overview> Important: If you’re working in a Swift codebase, always use ``doc://com.apple.uikit/documentation/UIKit/UITableViewDiffableDataSource-2euir`` instead.

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 [`UITableViewDataSource`](/documentation/UIKit/UITableViewDataSource) protocol and provides implementations for all of the protocol’s methods.

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/UIKit/UITableViewDiffableDataSourceReference/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.

```swift
self.dataSource = [[UITableViewDiffableDataSource alloc] initWithTableView:self.tableView cellProvider:^UITableViewCell *(UITableView *tableView, NSIndexPath *indexPath, id itemIdentifier) {
    // configure and return cell
}];
```

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/UIKit/NSDiffableDataSourceSnapshotReference).

> Important:
> Do not change the ``doc://com.apple.uikit/documentation/UIKit/UITableView/dataSource`` on the table view after you configure it with a diffable data source. If the table view needs a new data source after you configure it initially, create and configure a new table view and diffable data source.

## Topics

### Creating a diffable data source

[`-  initWithTableView:cellProvider:`](/documentation/UIKit/UITableViewDiffableDataSourceReference/init(tableView:cellProvider:))

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

[`UITableViewDiffableDataSourceReferenceCellProvider`](/documentation/UIKit/UITableViewDiffableDataSourceReferenceCellProvider)

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

### Identifying items

[`-  itemIdentifierForIndexPath:`](/documentation/UIKit/UITableViewDiffableDataSourceReference/itemIdentifier(for:))

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

[`-  indexPathForItemIdentifier:`](/documentation/UIKit/UITableViewDiffableDataSourceReference/indexPath(forItemIdentifier:))

Returns an index path for the item with the specified identifier in the table view.

### Identifying sections

[`-  sectionIdentifierForIndex:`](/documentation/UIKit/UITableViewDiffableDataSourceReference/sectionIdentifier(for:))

Returns an identifier for the section at the index you specify in the table view.

[`-  indexForSectionIdentifier:`](/documentation/UIKit/UITableViewDiffableDataSourceReference/index(forSectionIdentifier:))

Returns an index for the section with the identifier you specify in the table view.

### Updating data

[`-  snapshot`](/documentation/UIKit/UITableViewDiffableDataSourceReference/snapshot())

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

[`-  applySnapshot:animatingDifferences:`](/documentation/UIKit/UITableViewDiffableDataSourceReference/applySnapshot(_:animatingDifferences:))

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

[`-  applySnapshot:animatingDifferences:completion:`](/documentation/UIKit/UITableViewDiffableDataSourceReference/applySnapshot(_:animatingDifferences:completion:))

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

[`-  applySnapshotUsingReloadData:`](/documentation/UIKit/UITableViewDiffableDataSourceReference/applySnapshot(usingReloadData:))

Resets the UI to reflect the state of the data in the snapshot without computing a diff or animating the changes.

[`-  applySnapshotUsingReloadData:completion:`](/documentation/UIKit/UITableViewDiffableDataSourceReference/applySnapshot(usingReloadData:completion:))

Resets the UI to reflect the state of the data in the snapshot without computing a diff or animating the changes, optionally executing a completion handler.

[`defaultRowAnimation`](/documentation/UIKit/UITableViewDiffableDataSourceReference/defaultRowAnimation)

The default type of animation to use when inserting or deleting rows.

## Relationships

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

### Conforms To

[`Sendable`](/documentation/Swift/Sendable)

[`Hashable`](/documentation/Swift/Hashable)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`UITableViewDataSource`](/documentation/UIKit/UITableViewDataSource)

[`Equatable`](/documentation/Swift/Equatable)

[`CVarArg`](/documentation/Swift/CVarArg)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

---

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)