Skip to content

Instantly share code, notes, and snippets.

@wh1pch81n
Created April 21, 2017 03:56
Show Gist options
  • Save wh1pch81n/a30f0c0db78520411a9aef30efcf2ad9 to your computer and use it in GitHub Desktop.
Save wh1pch81n/a30f0c0db78520411a9aef30efcf2ad9 to your computer and use it in GitHub Desktop.
You can use a static var as if it were an enum case of an enum string.
class EnumString: NSObject {
let rawValue: String
init(rawValue: String = #function) {
self.rawValue = rawValue
}
static var abc: EnumString { return .init() }
static var defg: EnumString { return .init() }
static var hijk: EnumString { return .init() }
}
// Usage -----
// EnumString.abc.rawValue // "abc"
// EnumString.defg.rawValue // "defg"
// EnumString.hijk.rawValue // "hijk"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment