Created
February 6, 2020 20:12
-
-
Save BetterProgramming/8e6ebc19e312b80cad808ea8943e4faf 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 HeaderInformation: Decodable { | |
let title: String | |
let imageUrl: String | |
let textColor: UIColor | |
static var textColorUserInfoKey: CodingUserInfoKey { | |
return CodingUserInfoKey(rawValue: "textColor")! | |
} | |
init(from decoder: Decoder) throws { | |
let container = try decoder.container(keyedBy: CodingKeys.self) | |
title = try container.decode(String.self, forKey: .title) | |
imageUrl = try container.decode(String.self, forKey: .imageUrl) | |
textColor = decoder.userInfo[Self.textColorUserInfoKey] as? UIColor ?? .black | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment