Class

NSCollectionViewDiffableDataSourceReference

The Swift representation of the Objective-C object you use to manage data and provide items for a collection view.

Declaration

class NSCollectionViewDiffableDataSourceReference : NSObject

Overview

Topics

Creating a Diffable Data Source

init(collectionView: NSCollectionView, itemProvider: NSCollectionViewDiffableDataSourceReferenceItemProvider)

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

typealias NSCollectionViewDiffableDataSourceReferenceItemProvider

A closure that configures and returns an item for a collection view from its diffable data source.

Creating Supplementary Views

var supplementaryViewProvider: NSCollectionViewDiffableDataSourceReferenceSupplementaryViewProvider?

The closure that configures and returns the collection view’s supplementary views, such as headers and footers, from the diffable data source.

typealias NSCollectionViewDiffableDataSourceReferenceSupplementaryViewProvider

A closure that configures and returns a collection view’s supplementary view, such as a header or footer, from a diffable data source.

Identifying Items

func itemIdentifier(for: IndexPath) -> Any?

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

func indexPath(forItemIdentifier: Any) -> IndexPath?

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

Updating Data

func snapshot() -> NSDiffableDataSourceSnapshotReference

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

func applySnapshot(NSDiffableDataSourceSnapshotReference, animatingDifferences: Bool)

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