Skip to content

Instantly share code, notes, and snippets.

@colemancda
Created April 13, 2013 19:52
Show Gist options
  • Save colemancda/5379799 to your computer and use it in GitHub Desktop.
Save colemancda/5379799 to your computer and use it in GitHub Desktop.
Singleton Implementation
+ (<#Class#> *)shared<#short class name#>
{
static <#Class#> *shared<#short class name#> = nil;
if (!shared<#short class name#>) {
shared<#short class name#> = [[super allocWithZone:nil] init];
}
return shared<#short class name#>;
}
+ (id)allocWithZone:(NSZone *)zone
{
return [self shared<#short class name#>];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment