Created
August 15, 2017 02:51
-
-
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 ---
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+ (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