Quick tip: Enum class for defining constants in swift

Just in case someone will find it useful:

class MyClass {
    enum myConst: Int {
        case SomeValue = 1
    }
}

and then:

var aPlanet = MyClass.MyConst.SomeValue

or if you need int value:

var myInt = MyClass.MyConst.SomeValue.toRaw()

 

 

 

Leave a Reply