Skip to content

Instantly share code, notes, and snippets.

@danmartyn
Created July 16, 2013 05:09
Show Gist options
  • Save danmartyn/6005946 to your computer and use it in GitHub Desktop.
Save danmartyn/6005946 to your computer and use it in GitHub Desktop.
Singleton for Obj-C
+ (<#Class#> *)sharedManager
{
static <#Class#> *sharedManager = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
sharedManager = [[<#Class#> alloc] init];
// other initialisation stuff
});
return sharedManager;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment