Created
April 21, 2017 03:56
-
-
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.
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
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