Created
August 23, 2017 13:40
-
-
Save aratkevich/b5970c44f481729413685fe6fefba00f to your computer and use it in GitHub Desktop.
Singleton
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
import Foundation | |
class SingletonC : NSObject { | |
class var sharedInstance : SingletonC { | |
struct Static { | |
static var onceToken : dispatch_once_t = 0 | |
static var instance : SingletonC? = nil | |
} | |
dispatch_once(&Static.onceToken) { | |
Static.instance = SingletonC() | |
} | |
return Static.instance! | |
} | |
init() { | |
println("CCC"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment