Skip to content

Instantly share code, notes, and snippets.

@guillaumealgis
Last active August 29, 2015 13:56
Show Gist options
  • Save guillaumealgis/9271396 to your computer and use it in GitHub Desktop.
Save guillaumealgis/9271396 to your computer and use it in GitHub Desktop.
Objective-C Singleton
+ (instancetype)sharedInstance
{
static id sharedObject = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
sharedObject = [[self alloc] init];
});
return sharedObject;
}
@guillaumealgis
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment