Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save froggomad/55e2edaff6092d76322404bac7301fa3 to your computer and use it in GitHub Desktop.
Save froggomad/55e2edaff6092d76322404bac7301fa3 to your computer and use it in GitHub Desktop.
extension TitledCollectionView: UICollectionViewDelegate {
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
updateControllerDelegate(with: indexPath.item)
}
private func updateControllerDelegate(with item: Int) {
switch self.produce {
case .fruit:
let fruit = Fruit.allCases[item]
print(produce?.description, fruit.description)
case .vegetable:
let vegetable = Vegetable.allCases[item]
print(produce?.description, vegetable.description)
default: // nil value
break
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment