iosios13diffabledatasourcensdiffabledatasourcesnapshot

iOS13 DiffableDataSource Invalid parameter not satisfying: indexPath || ignoreInvalidItems


I'm converting my collection view to new iOS13 UICollectionViewDiffableDataSource... so I need to update cell information on demand.

Here is my code:

let snap = self.diffDataSouce.snapshot
snap?.reloadItems(withIdentifiers: [itemToUpdate]) //reload cell info
self.diffDataSouce.apply(snap, animatingDifferences: true)

But I get Invalid parameter not satisfying: indexPath || ignoreInvalidItems ...why? My current snap contains itemToUpdate and also my array of models...

I think it's because snap.indexOfItemIdentifier(itemToUpdate) returns not found (NSNotFound)...but that's should be impossible according data model.

Have you some hints?


Solution

  • I ran into this problem when I was attempting to reload items that had been deleted from my snapshot. This will get you the same or a similar error. Make sure you data model and snapshot are in sync to avoid this error.