If you require to have all the cases of a specific enumeration as an array then you can use CaseIterable
. You need to write CaseIterable
after enumeration name and swift will expose a property allCases
which is collection of all enumeration cases
enum Beverage: CaseIterable { case coffee, tea, juice } let numberOfChoices = Beverage.allCases.count print("\(numberOfChoices) beverages available") for beverage in Beverage.allCases { print(beverage) }