Skip to content

Instantly share code, notes, and snippets.

@radex
Created October 28, 2014 16:10
Show Gist options
  • Save radex/8833993186729399184d to your computer and use it in GitHub Desktop.
Save radex/8833993186729399184d to your computer and use it in GitHub Desktop.
Nested struct with static constants inside of a class is a neat way of managing magic string constants, like identifiers, user defaults or other dictionary keys, etc…
class Foo {
struct Keys {
static let keychainGroup = "com.foo.keychain-group"
static let enabled = "foo.enabled"
}
// now you can just write `Keys.enabled`, `Keys.keychainGroup` inside of the Foo class.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment