【发布时间】:2018-04-08 21:51:30
【问题描述】:
在 swift4 中使用 JSONDecodable 时出现以下错误。 "Type UserRegister does not confirm to protocol 'Decodable' "
我的模型结构如下所示。
struct UserRegister: Decodable {
let id : NSInteger
let name : String?
let email : String?
let cities : Array<Any>?
let tax : [tax]
let username : [username]
}
struct tax : Decodable {
let deviceId : NSInteger?
let financialYear : String?
let country : String?
let name : String?
let state : String?
let taxCode : String?
let value : NSInteger?
}
struct username : Decodable {
let email : String?
let phone : String?
}
【问题讨论】:
-
您的代码中没有
xxxxx类型,所以我怀疑错误是否说明了您所说的内容。 -
现在编辑问题。
-
另外请以大写字母开头的类型名称,例如
tax和username:Tax, Username。
标签: ios json swift swift4 jsondecoder