Skip to content

Instantly share code, notes, and snippets.

@michzio
Created May 3, 2020 10:23
Show Gist options
  • Save michzio/97fb248106ab0c49f4223dfc62ad0255 to your computer and use it in GitHub Desktop.
Save michzio/97fb248106ab0c49f4223dfc62ad0255 to your computer and use it in GitHub Desktop.
extension CollectionView {
class Coordinator: NSObject, UICollectionViewDelegate {
// MARK: - Properties
let parent: CollectionView
var dataSource: UICollectionViewDiffableDataSource<Section, Item>?
// MARK: - Init
init(_ parent: CollectionView) {
self.parent = parent
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
guard let item = dataSource?.itemIdentifier(for: indexPath) else { return }
print("Item selected: \(item)")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment