How to enable data prefetching when using the new Compositional Layout & DiffableDataSource?
Before, we can achieve this by conforming a custom data source object, like,
class CustomDataSource: NSObject, UICollectionViewDataSource, UICollectionViewDataSourcePrefetching
Now, the data source is the UICollectionViewDiffableDataSource
, which only conforms to UICollectionViewDataSource
.
One way is to extend it to conform to the prefetching protocol. However, due to the fact that it encapsulates protocol implementations of the DataSource into its higher level methods like snapshots
and apply
. I can't figure out how to extend it to conforms to the prefetching protocol.