Skip to content

Instantly share code, notes, and snippets.

@hechen
Created August 15, 2017 02:51
Show Gist options
  • Save hechen/9caefd3ad893dcb168e6d39c94ee24cc to your computer and use it in GitHub Desktop.
Save hechen/9caefd3ad893dcb168e6d39c94ee24cc to your computer and use it in GitHub Desktop.
--- title: "Shared Singleton" summary: "Class method that returns a singleton instance" completion-scope: Class Implementation ---
+ (instancetype)shared<#name#> {
static <#class#> *_shared<#name#> = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_shared<#name#> = <#initializer#>;
});
return _shared<#name#>;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment