Created
January 30, 2014 21:25
-
-
Save DanielKoehler/8720193 to your computer and use it in GitHub Desktop.
This file contains hidden or 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)singleton { | |
| static id singletonInstance = nil; | |
| if (!singletonInstance) { | |
| static dispatch_once_t onceToken; | |
| dispatch_once(&onceToken, ^{ | |
| singletonInstance = [[super allocWithZone:NULL] init]; | |
| }); | |
| } | |
| return singletonInstance; | |
| } | |
| + (id)allocWithZone:(NSZone *)zone { | |
| return [self singleton]; | |
| } | |
| - (id)copyWithZone:(NSZone *)zone { | |
| return self; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment