Revision: 46182
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at May 13, 2011 22:10 by paki
Initial Code
#import "SomeClass.h" static SomeClass *instance = nil; @implementation SomeClass #pragma mark - #pragma mark Singleton + (id)instance { @synchronized(self) { if (instance == nil) instance = [[super allocWithZone:NULL] init]; } return instance; } + (id)allocWithZone:(NSZone *)zone { return [[self instance] retain]; } - (id)copyWithZone:(NSZone *)zone { return self; } - (id)retain { return self; } - (unsigned)retainCount { return UINT_MAX; } - (void)release { // never release } - (id)autorelease { return self; } - (id)init { if (self = [super init]) { } return self; } @end
Initial URL
Initial Description
Initial Title
Singleton Class
Initial Tags
Initial Language
Objective C