Skip to content

Instantly share code, notes, and snippets.

@andrey-str
Forked from abbeyjackson/sharedInstance Singleton
Created May 4, 2016 13:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrey-str/b29f0aebf768bb2574167dbf6be824ef to your computer and use it in GitHub Desktop.
Save andrey-str/b29f0aebf768bb2574167dbf6be824ef to your computer and use it in GitHub Desktop.
sharedInstance singleton
+ (instancetype)sharedInstance
{
static dispatch_once_t once;
static id sharedInstance;
dispatch_once(&once, ^{
sharedInstance = [[self alloc] init];
});
return sharedInstance;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment