Last active
April 22, 2020 21:57
-
-
Save Galeas/7431739 to your computer and use it in GitHub Desktop.
Singleton in Interface Builder.
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)handler | |
{ | |
__strong static id *_sharedInstance = nil; | |
static dispatch_once_t onlyOnce; | |
dispatch_once(&onlyOnce, ^{ | |
_sharedInstance = [[self _alloc] _init]; | |
}); | |
return _sharedInstance; | |
} | |
+ (id) allocWithZone:(NSZone*)z | |
{ | |
return [self handler]; | |
} | |
+ (id) alloc | |
{ | |
return [self handler]; | |
} | |
- (id) init | |
{ | |
return self; | |
} | |
+ (id)_alloc | |
{ | |
return [super allocWithZone:NULL]; | |
} | |
- (id)_init | |
{ | |
self = [super init]; | |
if (self) { | |
// Common setup | |
} | |
return self; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
__strong static id *_sharedInstance = nil;
should beid _sharedInstance
without a*
.