Skip to content

Instantly share code, notes, and snippets.

@jzucker2
Last active March 8, 2016 17:44
Show Gist options
  • Save jzucker2/5bde84e5f0d05de689f5 to your computer and use it in GitHub Desktop.
Save jzucker2/5bde84e5f0d05de689f5 to your computer and use it in GitHub Desktop.
Singleton
#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