Swift: Enumerate / Iterate Enum
Swift: Enumerate / Iterate Enum avatar

In Swift, you cannot iterate over an enum by default. (This means an enum is not enumerable!).

This feature can be added by introducing a protocol, which inherits from RawRepresentable:

This can be further simplified to:

Note: This protocol can only be used on enums, which inherit from Int

(Taken from this thread.)