Skip to content

Instantly share code, notes, and snippets.

@danielgalasko
Last active August 29, 2015 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielgalasko/847a34d494160f34b34f to your computer and use it in GitHub Desktop.
Save danielgalasko/847a34d494160f34b34f to your computer and use it in GitHub Desktop.
A swift singleton initialiser that also allows for configuration of the singleton when it is first created.
class var sharedInstance {
struct Static {
static let instance : SingletonObject = SingletonObject()
static var onceToken : dispatch_once_t = 0
}
dispatch_once(&Static.onceToken) {
//perform configuration here
}
return Static.instance
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment