Last active
August 29, 2015 14:03
-
-
Save NorrinRadd/e1b4b3edf8144cdf5b95 to your computer and use it in GitHub Desktop.
singleton using init override
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
@interface blah : blah | |
-(id)init NS_UNAVAILABLE; | |
@end | |
@implementation | |
-(id)init{abort();} | |
-(instancetype)internalInit { | |
return [super init]; | |
} | |
+(instancetype)sharedInstance { | |
static dispatch_once_t once; | |
dispatch_once(&once, ^{ | |
sharedInstance = [[self alloc] internalInit]; | |
}); | |
return sharedInstance; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment