<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: -",
    "tvOS: 13.0.0 -",
    "visionOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UITableViewDiffableDataSource-2euir",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "s:5UIKit29UITableViewDiffableDataSourceC"
  },
  "title" : "UITableViewDiffableDataSource"
}
-->

# UITableViewDiffableDataSource

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

```
@MainActor @preconcurrency class UITableViewDiffableDataSource<SectionIdentifierType, ItemIdentifierType> where SectionIdentifierType : Hashable, SectionIdentifierType : Sendable, ItemIdentifierType : Hashable, ItemIdentifierType : Sendable
```

## Overview

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/UITableViewDiffableDataSource-2euir/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
dataSource = UITableViewDiffableDataSource<Int, UUID>(tableView: tableView) {
    (tableView: UITableView, indexPath: IndexPath, itemIdentifier: UUID) -> UITableViewCell? in
    // 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 [`NSDiffableDataSourceSnapshot`](/documentation/UIKit/NSDiffableDataSourceSnapshot-swift.struct).

> 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

[`init(tableView:cellProvider:)`](/documentation/UIKit/UITableViewDiffableDataSource-2euir/init(tableView:cellProvider:))

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

[`UITableViewDiffableDataSource.CellProvider`](/documentation/UIKit/UITableViewDiffableDataSource-2euir/CellProvider)

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

### Identifying items

[`itemIdentifier(for:)`](/documentation/UIKit/UITableViewDiffableDataSource-2euir/itemIdentifier(for:))

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

[`indexPath(for:)`](/documentation/UIKit/UITableViewDiffableDataSource-2euir/indexPath(for:))

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

### Identifying sections

[`sectionIdentifier(for:)`](/documentation/UIKit/UITableViewDiffableDataSource-2euir/sectionIdentifier(for:))

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

[`index(for:)`](/documentation/UIKit/UITableViewDiffableDataSource-2euir/index(for:))

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

### Updating data

[`snapshot()`](/documentation/UIKit/UITableViewDiffableDataSource-2euir/snapshot())

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

[`apply(_:animatingDifferences:)`](/documentation/UIKit/UITableViewDiffableDataSource-2euir/apply(_:animatingDifferences:))

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

[`apply(_:animatingDifferences:completion:)`](/documentation/UIKit/UITableViewDiffableDataSource-2euir/apply(_: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/UITableViewDiffableDataSource-2euir/applySnapshotUsingReloadData(_:))

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/UITableViewDiffableDataSource-2euir/applySnapshotUsingReloadData(_: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/UITableViewDiffableDataSource-2euir/defaultRowAnimation)

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

### Supporting bridging

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

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

### Debugging a diffable data source

[`description()`](/documentation/UIKit/UITableViewDiffableDataSource-2euir/description())

Returns a string with a description of the diffable data source.



---

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)