2
似乎println
不僅在Playground中,而且在單元測試中也忽略了可打印協議。這是真的還是我做錯了什麼?枚舉的可打印協議在單元測試中不起作用
這裏是我的代碼片段:
class ExampleTests: XCTestCase {
enum Directions: Printable {
case North
var description: String {
get {
switch self {
case .North:
return "North"
}
}
}
}
override func setUp() {
let direction = Directions.North
println(direction)
super.setUp()
}
}
在控制檯中我看到(Enum Value)
而不是North
。
我無法在相關問題中找到答案,並嘗試將其也用於Google。
注意。如果我將這段代碼移到我的ViewController中,它會正常工作。看起來很奇怪。
我現在有同樣的問題,不知道發生了什麼 – 2015-03-08 18:48:19
它似乎是我的一個xcode錯誤。 Swift發展非常快。也許這個錯誤將在未來的版本中修復。 – Alexander 2015-03-09 20:32:51