Skip to content

Instantly share code, notes, and snippets.

@a2
Created September 6, 2011 03:15
Show Gist options
  • Save a2/1196496 to your computer and use it in GitHub Desktop.
Save a2/1196496 to your computer and use it in GitHub Desktop.
ARC Singleton Boilerplates
#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