Skip to content

Instantly share code, notes, and snippets.

@eilonkr
Last active November 30, 2020 09:26
Show Gist options
  • Save eilonkr/f38b06193568a0c183d3e34d77a48240 to your computer and use it in GitHub Desktop.
Save eilonkr/f38b06193568a0c183d3e34d77a48240 to your computer and use it in GitHub Desktop.
// MARK: - Setup Logic
extension CollectionViewModel {
private func cellProvider(_ collectionView: UICollectionView, indexPath: IndexPath, item: Item) -> UICollectionViewCell? {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: cellIdentifier, for: indexPath) as! CellType
cell.provide(item)
return cell
}
public func makeDataSource() -> DataSource {
guard let collectionView = collectionView else { fatalError("CollectionView isn't here :(") }
let dataSource = DataSource(collectionView: collectionView, cellProvider: cellProvider)
self.dataSource = dataSource
return dataSource
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment