---
title: NSDiffableDataSourceSnapshotReference
framework: appkit
role: symbol
role_heading: Class
path: appkit/nsdiffabledatasourcesnapshotreference
---

# NSDiffableDataSourceSnapshotReference

A representation of the state of the data in a view at a specific point in time.

## Declaration

```swift
class NSDiffableDataSourceSnapshotReference
```

## Overview

Overview important: If you’re working in a Swift codebase, always use NSDiffableDataSourceSnapshot instead of NSDiffableDataSourceSnapshotReference. Diffable data sources use snapshots to provide data for collection views and table views. Through a snapshot, you set up the initial state of the data that displays in a view, and later update that data. The data in a snapshot is made up of the sections and items you want to display, in the specific order you want to display them. You configure what to display by adding, deleting, or moving the sections and items. important: Each of your sections and items must have unique identifiers. To display data in a view using a snapshot: Create a snapshot and populate it with the state of the data you want to display. Apply the snapshot to reflect the changes in the UI. You can create and configure a snapshot in one of these ways: Create an empty snapshot, then append sections and items to it. Get the current snapshot by calling the diffable data source’s snapshot() method, then modify that snapshot to reflect the new state of the data that you want to display. For example, the following code creates an empty snapshot, and populates it with a single section with three items. Then, it applies the snapshot, animating the UI updates between the previous state and the new state represented in the snapshot. For more information, see the diffable data source types: UICollectionViewDiffableDataSource UITableViewDiffableDataSource NSCollectionViewDiffableDataSourceReference Bridging Avoid using this type in Swift code. Only use this type to bridge from Objective-C code to Swift code by typecasting from a snapshot reference to a snapshot: let snapshot = snapshotReference as NSDiffableDataSourceSnapshot<Int, UUID>

## Topics

### Creating a snapshot

- [appendSections(withIdentifiers:)](appkit/nsdiffabledatasourcesnapshotreference/appendsections(withidentifiers:).md)
- [appendItems(withIdentifiers:intoSectionWithIdentifier:)](appkit/nsdiffabledatasourcesnapshotreference/appenditems(withidentifiers:intosectionwithidentifier:).md)
- [appendItems(withIdentifiers:)](appkit/nsdiffabledatasourcesnapshotreference/appenditems(withidentifiers:).md)

### Getting item and section metrics

- [numberOfItems](appkit/nsdiffabledatasourcesnapshotreference/numberofitems.md)
- [numberOfSections](appkit/nsdiffabledatasourcesnapshotreference/numberofsections.md)
- [numberOfItems(inSection:)](appkit/nsdiffabledatasourcesnapshotreference/numberofitems(insection:).md)

### Identifying items and sections

- [itemIdentifiers](appkit/nsdiffabledatasourcesnapshotreference/itemidentifiers.md)
- [sectionIdentifiers](appkit/nsdiffabledatasourcesnapshotreference/sectionidentifiers.md)
- [index(ofItemIdentifier:)](appkit/nsdiffabledatasourcesnapshotreference/index(ofitemidentifier:).md)
- [index(ofSectionIdentifier:)](appkit/nsdiffabledatasourcesnapshotreference/index(ofsectionidentifier:).md)
- [itemIdentifiersInSection(withIdentifier:)](appkit/nsdiffabledatasourcesnapshotreference/itemidentifiersinsection(withidentifier:).md)
- [sectionIdentifier(forSectionContainingItemIdentifier:)](appkit/nsdiffabledatasourcesnapshotreference/sectionidentifier(forsectioncontainingitemidentifier:).md)

### Inserting items and sections

- [insertItems(withIdentifiers:afterItemWithIdentifier:)](appkit/nsdiffabledatasourcesnapshotreference/insertitems(withidentifiers:afteritemwithidentifier:).md)
- [insertItems(withIdentifiers:beforeItemWithIdentifier:)](appkit/nsdiffabledatasourcesnapshotreference/insertitems(withidentifiers:beforeitemwithidentifier:).md)
- [insertSections(withIdentifiers:afterSectionWithIdentifier:)](appkit/nsdiffabledatasourcesnapshotreference/insertsections(withidentifiers:aftersectionwithidentifier:).md)
- [insertSections(withIdentifiers:beforeSectionWithIdentifier:)](appkit/nsdiffabledatasourcesnapshotreference/insertsections(withidentifiers:beforesectionwithidentifier:).md)

### Removing items and sections

- [deleteAllItems()](appkit/nsdiffabledatasourcesnapshotreference/deleteallitems().md)
- [deleteItems(withIdentifiers:)](appkit/nsdiffabledatasourcesnapshotreference/deleteitems(withidentifiers:).md)
- [deleteSections(withIdentifiers:)](appkit/nsdiffabledatasourcesnapshotreference/deletesections(withidentifiers:).md)

### Reordering items and sections

- [moveItem(withIdentifier:afterItemWithIdentifier:)](appkit/nsdiffabledatasourcesnapshotreference/moveitem(withidentifier:afteritemwithidentifier:).md)
- [moveItem(withIdentifier:beforeItemWithIdentifier:)](appkit/nsdiffabledatasourcesnapshotreference/moveitem(withidentifier:beforeitemwithidentifier:).md)
- [moveSection(withIdentifier:afterSectionWithIdentifier:)](appkit/nsdiffabledatasourcesnapshotreference/movesection(withidentifier:aftersectionwithidentifier:).md)
- [moveSection(withIdentifier:beforeSectionWithIdentifier:)](appkit/nsdiffabledatasourcesnapshotreference/movesection(withidentifier:beforesectionwithidentifier:).md)

### Reloading data

- [reloadItems(withIdentifiers:)](appkit/nsdiffabledatasourcesnapshotreference/reloaditems(withidentifiers:).md)
- [reloadSections(withIdentifiers:)](appkit/nsdiffabledatasourcesnapshotreference/reloadsections(withidentifiers:).md)

## Relationships

### Inherits From

- [NSObject](objectivec/nsobject-swift.class.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSCopying](foundation/nscopying.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
