Last active
August 29, 2015 14:09
-
-
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.
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 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