Created
May 26, 2015 02:17
-
-
Save HackingGate/9024e2a9f9a9c55fd8a2 to your computer and use it in GitHub Desktop.
Objective-C SingletonClass in GCD
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 "MySingletonClass.h" | |
static MySingletonClass *singleton = nil; | |
@implementation MySingletonClass | |
+ (MySingletonClass *)defaultSingleton{ | |
static dispatch_once_t onceToken; | |
dispatch_once(&onceToken, ^{ | |
singleton = [[MySingletonClass alloc] init]; | |
}); | |
return singleton; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment