Created
January 10, 2019 16:54
-
-
Save marslin1220/2614c5ceae8049bf144dc059a03686d5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DramaInfo: NSObject, Codable { | |
@objc public let currentEpisode: Int | |
@objc public let episodeID: String | |
@objc public let name: String | |
@objc public let viewCount: Int | |
@objc public let totalEpisode: Int | |
enum CodingKeys: String, CodingKey { | |
case currentEpisode = "currentEps" | |
case episodeID = "id" | |
case name = "name" | |
case viewCount = "views" | |
case totalEpisode = "totalEps" | |
} | |
public required init(from decoder: Decoder) throws { | |
let values = try decoder.container(keyedBy: CodingKeys.self) | |
currentEpisode = try values.decode(Int.self, forKey: .currentEpisode) | |
let episodeIDInt = try values.decode(Int.self, forKey: .episodeID) | |
episodeID = String(episodeIDInt) | |
name = try values.decode(String.self, forKey: .name) | |
viewCount = try values.decode(Int.self, forKey: .viewCount) | |
totalEpisode = try values.decode(Int.self, forKey: .totalEpisode) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment