Created
May 2, 2012 14:35
-
-
Save Kevinwlee/2576996 to your computer and use it in GitHub Desktop.
Love this Pattern for generating a single instance of an object
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
@implementation QTSomeClient | |
+ (QTSomeClient *)sharedClient { | |
static QTSomeClient *_sharedClient = nil; | |
static dispatch_once_t onceToken; | |
dispatch_once(&onceToken, ^{ | |
_sharedClient = [QTSomeClient new]; | |
}); | |
return _sharedClient; | |
} | |
- (id)init { | |
self = [super init]; | |
if (!self) { | |
return nil; | |
} | |
return self; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment