Last active
October 12, 2015 01:47
-
-
Save sey/3952150 to your computer and use it in GitHub Desktop.
Singleton class constructor method.
Makes use of instancetype (http://nshipster.com/instancetype/)
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)shared | |
{ | |
static id shared; | |
static dispatch_once_t token; | |
dispatch_once(&token, ^{ | |
shared = [[self alloc] init]; | |
}); | |
return shared; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment