<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: -",
    "tvOS: 13.0.0 -",
    "visionOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UITableViewDiffableDataSource-2euir/apply(_:animatingDifferences:completion:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "s:5UIKit29UITableViewDiffableDataSourceC5apply_20animatingDifferences10completionyAA010NSDiffableeF8SnapshotVyxq_G_SbyycSgtF"
  },
  "title" : "apply(_:animatingDifferences:completion:)"
}
-->

# 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.

```
@MainActor @preconcurrency func apply(_ snapshot: NSDiffableDataSourceSnapshot<SectionIdentifierType, ItemIdentifierType>, animatingDifferences: Bool = true, completion: (() -> Void)? = nil)
```

## Parameters

`snapshot`

The snapshot that reflects the new state of the data in the table view.

`animatingDifferences`

If <doc://com.apple.documentation/documentation/Swift/true>, the system animates the updates to the table view. If <doc://com.apple.documentation/documentation/Swift/false>, the system doesn’t animate the updates to the table view.

`completion`

A closure to execute when the animations are complete. This closure has no return value and takes no parameters. The system calls this closure from the main queue.

## Discussion

The diffable data source computes the difference between the table view’s current state and the new state in the applied snapshot, which is an O(*n*) operation, where *n* is the number of items in the snapshot.

You can safely call this method from a background queue, but you must do so consistently in your app. Always call this method exclusively from the main queue or from a background queue.

---

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)