looping through enum values

Viewed 74727

Is it possible to loop through enum values in Objective-C?

9 Answers

If the above does not work for you, because you're using C++, the following should:

enum Foo {
  One,
  Two,
  Three,
  Last
};

for ( int fooInt = One; fooInt != Last; fooInt++ )
{
   Foo foo = static_cast<Foo>(fooInt);
   // ...
}
Related