Created
June 19, 2021 05:00
-
-
Save froggomad/32822ae45152cc8172d1ee29d98245d6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] | |
delegate?.itemWasSelected(fruit) | |
case .vegetable: | |
let vegetable = Vegetable.allCases[item] | |
delegate?.itemWasSelected(vegetable) | |
default: // nil value | |
break | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment