Here is my enum:
enum myEnum : Int {
case apple = 0
case orange
case lemon
}
I would like to create it from an array. The array elements could be the name of the enums.
let myEnumDictionary : Array<String> = ["apple","orange","lemon"]
So is it possible to create enums from an array?
No, it's not possible. In the same way you can't create classes from arrays.
Enums must be compiled. You can't create them dynamically.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With