#import
"
Singleton.h
"
@implementation Singleton
static Singleton * sharedSingleton = nil;
+ (Singleton*) sharedInstance
{
if (sharedSingleton_ == nil)
{
sharedSingleton_ = [[super allocWithZone:NULL] init];
}
return sharedSingleton_;
}
+ ( id) allocWithZone:(NSZone *)zone
{
return [[self sharedInstance] retain];
}
- ( id) copyWithZone:(NSZone*)zone
{
return self;
}
- ( id) retain
{
return self;
}
- (NSUInteger) retainCount
{
return NSUIntegerMax; // denotes an object that cannot be released
}
- ( void) release
{
// do nothing
}
- ( id) autorelease
{
return self;
}
@end
@implementation Singleton
static Singleton * sharedSingleton = nil;
+ (Singleton*) sharedInstance
{
if (sharedSingleton_ == nil)
{
sharedSingleton_ = [[super allocWithZone:NULL] init];
}
return sharedSingleton_;
}
+ ( id) allocWithZone:(NSZone *)zone
{
return [[self sharedInstance] retain];
}
- ( id) copyWithZone:(NSZone*)zone
{
return self;
}
- ( id) retain
{
return self;
}
- (NSUInteger) retainCount
{
return NSUIntegerMax; // denotes an object that cannot be released
}
- ( void) release
{
// do nothing
}
- ( id) autorelease
{
return self;
}
@end