Last active
December 24, 2015 17:29
-
-
Save rblalock/6835920 to your computer and use it in GitHub Desktop.
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
static BOOL isLoaded; | |
/** | |
Singleton, shared instance | |
**/ | |
+ (id)sharedInstance | |
{ | |
__strong static id _sharedObject = nil; | |
if(isLoaded == NO) { | |
isLoaded = YES; | |
_sharedObject = [[self alloc] init]; | |
} | |
return _sharedObject; | |
} |
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
// Probably a better way. | |
/** | |
Singleton, shared instance | |
**/ | |
+ (id)sharedInstance | |
{ | |
static dispatch_once_t p = 0; | |
__strong static id _sharedObject = nil; | |
dispatch_once(&p, ^{ | |
_sharedObject = [[self alloc] init]; | |
}); | |
return _sharedObject; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment