Created
April 15, 2013 06:44
-
-
Save tempos21ios/5386166 to your computer and use it in GitHub Desktop.
Singleton (manual reference counting)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static MyClass *sharedMyManager = nil; | |
+ (MyClass*)sharedInstance | |
{ | |
if (sharedMyManager == nil) { | |
sharedMyManager = [[super allocWithZone:NULL] init]; | |
} | |
return sharedMyManager; | |
} | |
+ (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 | |
} | |
- (oneway void)release | |
{ | |
//do nothing | |
} | |
- (id)autorelease | |
{ | |
return self; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment