Skip to content

Instantly share code, notes, and snippets.

@fousa
Created July 12, 2012 10:09
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fousa/3097175 to your computer and use it in GitHub Desktop.
Save fousa/3097175 to your computer and use it in GitHub Desktop.
GCD Singleton
+ (MyClass *)sharedInstance {
static dispatch_once_t _predicate;
static MyClass *_sharedInstance = nil;
dispatch_once(&_predicate, ^{
_sharedInstance = [self new];
});
return _sharedInstance;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment