如何正确创建符合ErrorType的枚举

时间:2015-09-23 15:23:39

标签: ios error-handling enums swift2

我在Xcode 7中使用Swift 2.0 根据指南,我为自定义错误类型定义了一个枚举:

enum MyCustomError: ErrorType {
    case Error1(retries: Int)
    case Error2
    case Error3(message: NSString)
}

但我收到以下错误:

  1. Raw type 'ErrorType' is not convertible from any literal
  2. Type 'MyCustomError' does not conform to protocol 'RawRepresentable'
  3. 我该如何解决这个问题? 提前谢谢。

0 个答案:

没有答案