swift enum to int code example
Example 1: swift enum
enum Planet {
case mercury, venus, earth, mars, jupiter, saturn, uranus, neptune
}
Example 2: enum raw value swift
enum numbers: Int {
case one = 1, two, three, four
}
let num = numbers.one
print(num.rawValue) // Output: 1