Skip to content

Instantly share code, notes, and snippets.

@mikeyward
Created January 1, 2013 21:35
Show Gist options
  • Select an option

  • Save mikeyward/4430204 to your computer and use it in GitHub Desktop.

Select an option

Save mikeyward/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