Created
September 6, 2011 03:15
-
-
Save a2/1196496 to your computer and use it in GitHub Desktop.
ARC Singleton Boilerplates
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 SYNTHESIZE_SINGLETON_FOR_CLASS_WITH_CUSTOM_METHOD(className, methodName) \ | |
\ | |
+ (className *) methodName \ | |
{ \ | |
static className *shared ## className; \ | |
static dispatch_once_t token; \ | |
dispatch_once(&token, ^{ \ | |
shared ## className = [[className alloc] init]; \ | |
}); \ | |
\ | |
return shared ## className; \ | |
} | |
#define SYNTHESIZE_SINGLETON_FOR_CLASS(className) \ | |
\ | |
SYNTHESIZE_SINGLETON_FOR_CLASS_WITH_CUSTOM_METHOD(className, sharedInstance) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment