Created
October 21, 2015 10:04
-
-
Save crowjdh/2556078608d8c0a3b079 to your computer and use it in GitHub Desktop.
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
final class Singleton { | |
// MARK: - Singleton | |
private struct Instance { | |
static var dispatchToken: dispatch_once_t = 0 | |
static var instance: Singleton? | |
} | |
static var instance: Singleton { | |
get { | |
dispatch_once(&Instance.dispatchToken) { | |
Instance.instance = Singleton() | |
} | |
return Instance.instance! | |
} | |
} | |
// MARK: - Initializers | |
private init() { } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment