My understanding is that UICollectionViewDataSourcePrefetching is built for UICollectionViewDataSource, whereas UICollectionViewDiffableDataSource doesn't seem to have any documentation around prefetching.
Your implementation of UICollectionViewDataSourcePrefetching is set on a separate property of UICollectionView called prefetchDataSource
https://developer.apple.com/documentation/uikit/uicollectionview/1771768-prefetchdatasource
You will need to cache your prefetched data somewhere, and then access it from your cellProvider (or UICollectionView.CellRegistration). On your collection view you assign your prefetch data source to the prefetchDataSource property — this may just be your view controller e.g:
myCollectionView.prefetchDataSource = self
I've used this with UICollectionViewDiffableDataSource and the prefetch data source is consulted for the index paths to prefetch as the collection view is scrolled, while the actual data is supplied by the diffable data source
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With