Created
June 28, 2014 07:57
-
-
Save jhurliman/1f4c62298e77af4db32b to your computer and use it in GitHub Desktop.
Singleton pattern in Objective-C
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
+ (instancetype)sharedInstance { | |
static id instance; | |
static dispatch_once_t onceToken; | |
dispatch_once(&onceToken, ^{ | |
instance = [[self alloc] init]; | |
}); | |
return instance; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment