NSDiffableDataSourceSectionSnapshot reload items or the whole section

299 Views Asked by At

When you have a NSDiffableDataSourceSnapshot you can perform a reload on any section/item. NSDiffableDataSourceSnapshot

Whereas when you have a NSDiffableDataSourceSectionSnapshot I can't do any reload.

NSDiffableDataSourceSectionSnapshot

I would like to refresh a specific item because after creating the snapshot I need to trigger the reload via collapsing the section and then expanding it again in order to my cell registration set the cell properly with the updated tag.

1

There are 1 best solutions below

0
Bgr On

In my opinion, collapsing and expanding an item which own child items doesn't produce a refresh of cells. With value type data (struct, not class), to refresh a parent item, you need to delete and insert the parent, then recreate the child. To refresh a child, simply delete and insert a value which contains a modification of the index data for the snapshot. If the modification doesn't change the index, the cell won't be refreshed.