Skip to content

Instantly share code, notes, and snippets.

@Oni-zerone
Last active October 21, 2018 15:11
Show Gist options
  • Save Oni-zerone/675222691695b289089de4c6ca929560 to your computer and use it in GitHub Desktop.
Save Oni-zerone/675222691695b289089de4c6ca929560 to your computer and use it in GitHub Desktop.
A UICollectionViewDataSource that will use a ViewModel representation of the items inside the collection
protocol ItemViewModel {
var reuseIdentifier: String { get }
func setup(_ cell: UICollectionReusableView, in collectionView: UICollectionView, at indexPath: IndexPath)
}
protocol SectionViewModel {
var headerItem: ItemViewModel? { get }
var items: [ItemViewModel] { get }
var footer: ItemViewModel? { get }
func model(for elementOfKind: String) -> ItemViewModel?
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment