Created
February 28, 2019 11:14
-
-
Save chamook/4e4e3a5400e8aea9c51239a625bead2c 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 RGB: Decodable { | |
var red: Int | |
var green: Int | |
var blue: Int | |
enum CodingKeys: String, CodingKey { | |
case red = "Red" | |
case green = "Green" | |
case blue = "Blue" | |
} | |
} | |
struct Colour: Decodable { | |
var id: String | |
var name: String | |
var hex: String | |
var rgb: RGB | |
enum CodingKeys: String, CodingKey { | |
case id = "Id" | |
case name = "Name" | |
case hex = "Hex" | |
case rgb = "RGB" | |
} | |
} | |
private func loadColours() { | |
let url = URL(string: "http://localhost:5000/my-colours")! | |
var request = URLRequest(url: url) | |
request.setValue("application/vnd.chamook.api+json; including=id,name,hex,rgb", forHTTPHeaderField: "Accept") | |
... | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment