【问题标题】:Enum property in swift 3 can't accessibleswift 3中的枚举属性无法访问
【发布时间】:2017-03-22 09:00:33
【问题描述】:

在我的程序中,我想使用 SwiftyJSONModel 库。但是在实现模型类时会出现以下错误

【问题讨论】:

    标签: ios swift3 swifty-json


    【解决方案1】:

    JSONObject 的PropertyKey.RawValueString 所以使用字符串值:

    enum PropertyKey: String {
        case error = "Error"
    }
    
    class ViewController: UIViewController {
    
            override func viewDidLoad() {
                super.viewDidLoad()
    
                /* Here you can see the proper access to the enum case 
                   do the same in your code
                */
    
                let str: String = PropertyKey.error.rawValue
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-05-08
      • 2014-06-01
      • 1970-01-01
      • 1970-01-01
      • 2019-09-13
      • 2011-12-09
      • 1970-01-01
      • 2018-01-09
      相关资源
      最近更新 更多