Skip to content

Instantly share code, notes, and snippets.

@bouchtaoui-dev
Created December 2, 2017 17:45
Show Gist options
  • Select an option

  • Save bouchtaoui-dev/bae774b3cfed33acd0d006f98f9321d8 to your computer and use it in GitHub Desktop.

Select an option

Save bouchtaoui-dev/bae774b3cfed33acd0d006f98f9321d8 to your computer and use it in GitHub Desktop.
@interface Singleton : NSObject
@end
@implementation Singleton
+ (instancetype)sharedInstance {
static Singleton *sharedInstance = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
sharedInstance = [[Singleton alloc] init];
});
return sharedInstance;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment