Last active
March 8, 2016 17:44
-
-
Save jzucker2/5bde84e5f0d05de689f5 to your computer and use it in GitHub Desktop.
Singleton
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
#import <Foundation/Foundation.h> | |
@interface Singleton : NSObject | |
+ (instancetype)sharedManager; | |
@end | |
@implementation Singleton | |
+ (instancetype)sharedInstance { | |
static Singleton *sharedInstance = nil; | |
static dispatch_once_t onceToken; | |
dispatch_once(&onceToken, ^{ | |
sharedInstance = [[self alloc] init]; | |
}); | |
return sharedInstance; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment