Skip to content

Instantly share code, notes, and snippets.

@aratkevich
Created August 23, 2017 13:40
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 aratkevich/b5970c44f481729413685fe6fefba00f to your computer and use it in GitHub Desktop.
Save aratkevich/b5970c44f481729413685fe6fefba00f to your computer and use it in GitHub Desktop.
Singleton
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