Skip to content

Instantly share code, notes, and snippets.

@crowjdh
Created October 21, 2015 10:04
Show Gist options
  • Save crowjdh/2556078608d8c0a3b079 to your computer and use it in GitHub Desktop.
Save crowjdh/2556078608d8c0a3b079 to your computer and use it in GitHub Desktop.
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