Skip to content

Instantly share code, notes, and snippets.

@wookiee
Created January 1, 2013 21:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wookiee/4430204 to your computer and use it in GitHub Desktop.
Save wookiee/4430204 to your computer and use it in GitHub Desktop.
singleton shared instance creation with dispatch_once()
+ (id)sharedInstance
{
static dispatch_once_t onceQueue;
static <#Type#> *instance = nil;
dispatch_once(&onceQueue, ^{ instance = [[self alloc] init]; });
return instance;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment