Skip to content

Instantly share code, notes, and snippets.

@tempos21ios
Created April 15, 2013 06:45
Show Gist options
  • Save tempos21ios/5386172 to your computer and use it in GitHub Desktop.
Save tempos21ios/5386172 to your computer and use it in GitHub Desktop.
Singleton (ARC)
static ClassName* shared = nil;
+ (ClassName *)sharedInstance
{
if(!shared)
{
static dispatch_once_t pred; // Lock
dispatch_once(&pred, ^{ // This code is called at most once per app
shared = [[ClassName alloc] init];
});
}
return shared;
}
- (void) dealloc
{
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment