Skip to content

Instantly share code, notes, and snippets.

@michzio
Created May 3, 2020 09:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michzio/8a7ef8e188e5c7d84068b9626e390013 to your computer and use it in GitHub Desktop.
Save michzio/8a7ef8e188e5c7d84068b9626e390013 to your computer and use it in GitHub Desktop.
extension CollectionViewController {
private func cellProvider(_ collectionView: UICollectionView, _ indexPath: IndexPath, _ item: Item) -> UICollectionViewCell? {
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: HostingControllerCollectionViewCell<AnyView>.reuseIdentifier, for: indexPath) as? HostingControllerCollectionViewCell<AnyView> else {
fatalError("Could not load cell")
}
cell.host(content(indexPath, item))
cell.backgroundColor = .green
return cell
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment