Skip to content

Instantly share code, notes, and snippets.

@mafis
Created January 19, 2011 18:43
Show Gist options
  • Select an option

  • Save mafis/786619 to your computer and use it in GitHub Desktop.

Select an option

Save mafis/786619 to your computer and use it in GitHub Desktop.
#import <Cocoa/Cocoa.h>
@interface <#(ClassName *)className#> : NSObject
{
}
+ (<#(ClassName *)className#>*)sharedInstance;
@end
#import "Singleton.h"
static <#(ClassName *)className#>* SharedInstance;
@implementation <#(ClassName *)className#>
+ (<#(ClassName *)className#>*)sharedInstance
{
return SharedInstance ?: [[self new] autorelease];
}
- (id)init
{
if(SharedInstance)
{
[self release];
}
else if(self = SharedInstance = [[super init] retain])
{
/* init code */
}
return SharedInstance;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment