在Xcode 6.1中,枚举toRaw和fromRaw函数不再起作用:
toRaw
fromRaw
enum TestEnum : String { case A = "a" case B = "b" } if let a = TestEnum.fromRaw("a") { prinln(a.toRaw()) }
错误:
'TestEnum' does not have a member named 'toRaw' 'TestEnum.Type' does not have a member named 'fromRaw'
使用失败的初始化器从原始创建枚举,rawValue并使用属性获取原始值rawValue。
rawValue
if let a = TestEnum(rawValue: "a") { println(a.rawValue) }
阅读变更日志以获取更多信息。