NSDiffableDataSourceSectionSnapshotReference
A representation of the state of the data in a layout section at a specific point in time.
Declaration
class NSDiffableDataSourceSectionSnapshotReferenceOverview
A section snapshot represents the data for a single section in a collection view. Through a section snapshot, you set up the initial state of the data that displays in an individual section of your view, and later update that data.
You can use section snapshots with or instead of an NSDiffableDataSourceSnapshotReference, which represents the data in the entire view. Use a section snapshot when you need precise management of the data in a section of your layout, such as when the sections of your layout acquire their data from different sources. You can also use a section snapshot to represent data with a hierarchical structure, such as an outline with expandable items.
The following example creates a section snapshot with one root item that contains three child items:
for (NSNumber *section in sections) {
// Create a section snapshot.
NSDiffableDataSourceSectionSnapshot<NSString *> *sectionSnapshot = [[NSDiffableDataSourceSectionSnapshot alloc] init];
// Populate the section snapshot.
[sectionSnapshot appendItems: @[@"Food", @"Drinks"]];
[sectionSnapshot appendItems: @[@"🍏", @"🍓", @"🥐"] intoParentItem: @"Food"];
// Apply the section snapshot.
[dataSource applySnapshot: sectionSnapshot
toSection: section
animatingDifferences: YES];
}Avoid using this type in Swift code. Only use this type to bridge from Objective-C code to Swift code by typecasting from a section snapshot reference to a section snapshot:
let sectionSnapshot = sectionSnapshotRef as NSDiffableDataSourceSectionSnapshot<UUID>Topics
Creating a section snapshot
init()ofParentItem(_:)ofParentItem(_:includingParentItem:)appendItems(_:)appendItems(_:intoParentItem:)