【发布时间】:2015-02-08 19:54:53
【问题描述】:
似乎println 不仅在 Playground 中而且在单元测试中都忽略了 Printable 协议。是真的还是我做错了什么?
这是我的代码 sn-p:
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。
我在so中找不到相关问题的答案,并尝试用谷歌搜索。
注意。如果我将此代码移动到我的 ViewController 中,它会正常工作。对我来说看起来很奇怪。
【问题讨论】:
-
我现在也遇到同样的问题,不知道怎么回事
-
对我来说这似乎是一个 xcode 错误。 Swift 的发展非常迅速。也许这个错误会在未来的版本中修复。
标签: ios unit-testing swift enums protocols