Contents

snapshotForExpandingParentItemHandler

The handler that provides the section snapshot for expanding the parent item.

Declaration

@property (nonatomic, copy) NSDiffableDataSourceSectionSnapshot<id> * (^snapshotForExpandingParentItemHandler)(ItemType , NSDiffableDataSourceSectionSnapshot<id> *);

Discussion

Use the snapshotForExpandingParentItemHandler handler to customize the snapshot that returns when a particular parent item is expanded.

// Allow every item to be collapsed
dataSource.sectionSnapshotHandlers.shouldCollapseItem = { item in return true }

dataSource.sectionSnapshotHandlers.snapshotForExpandingParent = {
    parent, existingSnapshot -> NSDiffableDataSourceSectionSnapshot<String> in
    
    // Return child snapshot for the parent, or just existingSnapshot
}

See Also

Expanding and collapsing items