Hi there, I'm Marcos!


Enums with raw values

This is how you can define an enum in Swift with raw values for each enum value:

enum Periodicity: Int {
    case weekly = 7
    case monthly = 30
    case yearly = 365

If you want to get the wrapped value you wan use the .rawValue property:

let periodicity: Periodicity = .weekly

let days = periodicity.rawValue