Skip to content

Instantly share code, notes, and snippets.

@icodebuster
Created February 17, 2014 10:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save icodebuster/9048063 to your computer and use it in GitHub Desktop.
Save icodebuster/9048063 to your computer and use it in GitHub Desktop.
App Singleton
#import <Foundation/Foundation.h>
@interface AppSingleton : NSObject
+ (AppSingleton *)sharedInstance;
@end
#import "AppSingleton.h"
@implementation AppSingleton
+ (AppSingleton *)sharedInstance {
static AppSingleton *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