Instantly share code, notes, and snippets.

Embed
What would you like to do?
#import "Singleton.h"
@implementation Singleton
+ (id) sharedInstance{
NSLog(@"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");
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment