Instantly share code, notes, and snippets.

What would you like to do?
#import "Singleton.h"
@implementation Singleton
+ (id) sharedInstance{
static Singleton *instance = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
NSLog(@"I am called once");
instance = [ [self alloc] init];
return instance;
- (void) foo{
NSLog(@"i am called");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment