Skip to content

Instantly share code, notes, and snippets.

@vlchapaev
Created April 27, 2017 07:31
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 vlchapaev/7d7da9997bfc3c6831e57269e6ca2194 to your computer and use it in GitHub Desktop.
Save vlchapaev/7d7da9997bfc3c6831e57269e6ca2194 to your computer and use it in GitHub Desktop.
Objective-C Shared instance
+ (instancetype)sharedInstance {
static Instance *sharedInstance = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
sharedInstance = [[Instance alloc] init];
});
return sharedInstance;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment