0

I know this question has been asked before, but the older answers were for Swift 1. Is it possible to iterate through all the possible values of an enum type in Swift 2?

The goal is to have something like:

enum Foo {
  case Bar
  case Baz
  case Quux
}

for value in MYSTERY_OPERATION(Foo) {
  print(value)
}

print:

Bar
Baz
Quux
Bill
  • 44,502
  • 24
  • 122
  • 213
  • Have you had a look at this? http://stackoverflow.com/questions/32212160/introspection-and-iteration-on-an-enum – joern Oct 12 '15 at 16:28
  • 1
    I already gave a pretty good answer for Swift 2.0 here: http://stackoverflow.com/a/32429125/3443689 – Kametrixom Oct 12 '15 at 17:24

0 Answers0