Last active
November 21, 2015 13:58
-
-
Save ylem/4018420 to your computer and use it in GitHub Desktop.
Object-C create singleton class
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
+ (instancetype)sharedInstance | |
{ | |
static MyClass *sharedInstance = nil; | |
static dispatch_once_t onceToken; | |
dispatch_once(&onceToken, ^{ | |
sharedInstance = [[MyClass alloc] init]; | |
}); | |
return sharedInstance; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment