Skip to content

Instantly share code, notes, and snippets.

@wjlafrance
Created October 30, 2013 23:14
Show Gist options
  • Save wjlafrance/7241927 to your computer and use it in GitHub Desktop.
Save wjlafrance/7241927 to your computer and use it in GitHub Desktop.
/**
* Creates a dispatch_once style singleton.
*
* SINGLETON(NSString *awesomeString)
* awesomeString = [NSString stringWithFormat:@"%@ %@", @"composed", @"string"];
* SINGLETON_END(awesomeString)
*/
#define SINGLETON(name) static name; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{
#define SINGLETON_END(name) }); return name;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment