I am able to statically load data and have it display in a CollectionView Diffable / Snapshot view without any problems. But I am getting the following crash ‘Thread 1: Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value’ when attempting to update the data from modal viewController.
I am using a shared instance pass data between the viewControllers, and I can use a print statement to see that the data is getting appended. I also tried to update the data on the main queue, but I still got the same error.
Here’s the code that I am using, and would appreciate any help.
func update(data: [Data]) {
var snapshot = NSDiffableDataSourceSnapshot<Section, Data>()
snapshot.appendSections([.main])
snapshot.appendItems(data)
self.dataSource.apply(snapshot, animatingDifferences: true, completion: nil)
}
Thanks,