Created
March 27, 2019 09:48
-
-
Save randomguy0815/d108969879d096fccab3d13b05b71cd0 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
struct EnumModelRawValue: Decodable { | |
enum Keys: CodingKey { | |
case status | |
} | |
enum Status: String { | |
case enabled | |
case disabled | |
case unsupported | |
} | |
let status: Status | |
init(from decoder: Decoder) throws { | |
let container = try decoder.container(keyedBy: Keys.self) | |
let statusValue = try container.decode(String.self, forKey: .status) | |
self.status = Status(rawValue: statusValue) ?? .unsupported | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment