Swift - Cast Int into enum:Int
Use the rawValue
initializer: it's an initializer automatically generated for enum
s.
self.timeFilterSelected = MyTimeFilter(rawValue: (sender as UIButton).tag)!
see: The Swift Programming Language § Enumerations
NOTE: This answer has changed. Earlier version of Swift use the class method fromRaw()
to convert raw values to enumerated values.