Questions tagged «swift4»

仅对与Apple的Swift编程语言的版本4的更改直接相关的问题使用此标记。使用标签[swift]来解决更常见的语言问题,或使用标签[ios],[cocoa],[apple-watch]等来解决有关在Apple平台上开发的问题。

7
在带有继承的Swift 4中使用Decodable
使用类继承是否会破坏类的可解码性。例如下面的代码 class Server : Codable { var id : Int? } class Development : Server { var name : String? var userId : Int? } var json = "{\"id\" : 1,\"name\" : \"Large Building Development\"}" let jsonDecoder = JSONDecoder() let item = try jsonDecoder.decode(Development.self, from:json.data(using: .utf8)!) as Development print(item.id ?? …
72 swift  swift4  codable 
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.