Last active
September 25, 2020 17:07
-
-
Save giovani-pereira-ifood/008f262283b70339e73cc0a3ebadc1a7 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
enum Icon { | |
case alert | |
case car | |
case person | |
... | |
} | |
extension Icon { | |
var stringValue: String? { | |
let items = JSONDecoder().decode([IconDescription], from: json) | |
return items.first { $0.name == self.rawValue }?.char | |
} | |
} | |
fileprivate struct IconDescription: Codable { | |
let name: String | |
let char | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment