Created
November 24, 2013 03:11
-
-
Save rismay/7622846 to your computer and use it in GitHub Desktop.
Easy singleton. Add this to your PCH and every class will be singletonable. Exercise caution.
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
#define WSM_SINGLETON_WITH_NAME(sharedInstanceName) \ | |
+ (instancetype) sharedInstanceName { \ | |
static id sInstance; \ | |
static dispatch_once_t onceToken; \ | |
dispatch_once(&onceToken, ^{ \ | |
sInstance = [[self alloc] init]; \ | |
}); \ | |
return sInstance; \ | |
} \ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment