iosswiftuicollectionviewdiffabledatasource

UICollectionViewDiffableDataSource snapshot for static cell


In my UICollectionView, I have a header supplementary view that is static and doesn't receive any value to be configured.

So, when I'm creating a snapshot for UICollectionViewDiffableDataSource, I need to pass something like () for this section as a data, to fill the section with something. But () is not Hashable, so it doesn't work.

So, how to work with the static content like that when I'm generally using diffable data source to populate UICollectionView?


Solution

  • Have you tried creating a dummy data structure that conforms to the Hashable protocol and just pass it in?

    https://developer.apple.com/documentation/swift/hashable