Skip to content

Instantly share code, notes, and snippets.

@sey
Last active October 12, 2015 01:47
Show Gist options
  • Save sey/3952150 to your computer and use it in GitHub Desktop.
Save sey/3952150 to your computer and use it in GitHub Desktop.
Singleton class constructor method. Makes use of instancetype (http://nshipster.com/instancetype/)
+ (instancetype)shared
{
static id shared;
static dispatch_once_t token;
dispatch_once(&token, ^{
shared = [[self alloc] init];
});
return shared;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment