我正在使用一些基本的Swift操作。使用滑塊,我想指定一個相應的標籤。由於滑塊使用int
來表示位置,因此我將使用枚舉進行轉換。在枚舉中使用int作爲一個例子
enum Temperature: Int {
case 0 = "Zero"
case 1 = "One"
case 2 = "Two"
case 3 = "Three"
}
而且我想這樣稱呼它:
variable = Temperature.0
任何幫助將是理想的。請讓我知道你的想法。
謝謝!
Document here: - http://stackoverflow.com/documentation/swift/224/enums#t=201607271236068847981 –
我不認爲這是可能的。這是設計。在swift中枚舉的情況下必須有一個名稱(String),但不是Int。 –