Swift Enumerations .toRaw and .fromRaw with Xcode 6.1

前端 未结 2 1759
北海茫月
北海茫月 2020-12-17 07:52

In Xcode 6.1, the enumerations toRaw and fromRaw functions don\'t work anymore:

enum TestEnum : String {
    case A = \"a\"
    cas         


        
2条回答
  •  粉色の甜心
    2020-12-17 08:28

    Create an enum from a raw using the failable initializer with rawValue and get the raw value using the attribute rawValue.

    if let a = TestEnum(rawValue: "a") {
         println(a.rawValue)
    }
    

    Read the changelog for more information.

提交回复
热议问题