Last active
August 29, 2015 14:16
-
-
Save ivangodfather/c19daf03e3b94c15781a to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Singleton { | |
| class var sharedInstance: Singleton { | |
| var name: String? | |
| struct Static { | |
| static var instance: Singleton? | |
| static var token: dispatch_once_t = 0 | |
| } | |
| dispatch_once(&Static.token) { | |
| Static.instance = Singleton() | |
| } | |
| return Static.instance! | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Swift 1.1:
Swift 1.2: