Created
March 20, 2015 21:53
-
-
Save kaloprominat/82a5e60e0b7b4f263108 to your computer and use it in GitHub Desktop.
xcode objective-c singleton instance gcd example
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
+ (Singleton *)sharedSingleton | |
{ | |
static Singleton *sharedInstance = nil; | |
static dispatch_once_t onceToken; | |
dispatch_once(&onceToken, ^{ | |
sharedInstance = [[Singleton alloc] init]; | |
}); | |
return sharedInstance; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment