Skip to content

Instantly share code, notes, and snippets.

@Bersaelor
Created August 5, 2015 08:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Bersaelor/178b4195c24d1660b7ad to your computer and use it in GitHub Desktop.
Save Bersaelor/178b4195c24d1660b7ad to your computer and use it in GitHub Desktop.
enum Fonts {
case H1
case H2
case H3
case SomethingElse(value: String)
var jsonKey: String {
switch self {
case H1:
return "H1"
case H2:
return "H2"
case H3:
return "H3"
case SomethingElse(let value):
return value
}
}
init(rawValue: String) {
switch rawValue {
case "H1":
self = .H1
case "H2":
self = .H2
case "H3":
self = .H3
default:
self = .SomethingElse(value: rawValue)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment