Created
July 12, 2019 04:42
-
-
Save jinjereu/b8899f5b1f16fb41ecba874484a880ca to your computer and use it in GitHub Desktop.
Implement Objective-C 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
@implementation MySingletonClass | |
+ (MySingletonClass *)sharedInstance | |
{ | |
static MySingletonClass *sharedInstance; | |
static dispatch_once_t onceToken; | |
dispatch_once(&onceToken, ^{ | |
sharedInstance = [self new]; | |
//Perform additional initialization | |
}); | |
return sharedInstance; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment