【问题标题】:Printable protocol for enum doesn't work in unit tests枚举的可打印协议在单元测试中不起作用
【发布时间】: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


【解决方案1】:

该问题已在 Xcode 6.3 版中修复。谢谢你,苹果 :)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-05
    • 2016-05-09
    • 2016-04-26
    • 1970-01-01
    相关资源
    最近更新 更多