Last active
July 27, 2020 17:19
-
-
Save giovani-pereira-ifood/6972c0737324821b64ee0e9996e03987 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 User: Codable { | |
let name: String | |
let color: Color? | |
enum Color: String, Codable { | |
case red = "RED" | |
case yelllow = "YELLOW" | |
case blue = "BLUE" | |
} | |
} | |
// { | |
// "name": "Kermaine", | |
// "color": "GREEN" | |
// } | |
let data = requestData() | |
let decoder = JSONDecoder() | |
let object = try? decoder.decode(User.self, from: data) | |
print(object) // nil |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment