The Power of Enumerations in Swift

Enumerations in Swift are very powerful tool, here are some of their advantages over normal Objective C enums :

  1. It can have functions and stored properties.
  2. It can implement protocols (as classes and structs)
  3. It can take non Integer values (like Strings )
  4. It can have what is called “associated values” which simply can make the enum take various types of values and handle them all

The best way to show all these features is some examples :

Continue reading “The Power of Enumerations in Swift”