Skip to content

Instantly share code, notes, and snippets.

@patzearfoss
Created March 19, 2014 15:51
Show Gist options
  • Save patzearfoss/9644671 to your computer and use it in GitHub Desktop.
Save patzearfoss/9644671 to your computer and use it in GitHub Desktop.
/// .h
@interface mySingleton : NSObject
@property (nonatomic, strong) id someData;
+ (id)sharedInstance;
+ (void)probablySuperfluousStartup;
+ (void)probablyUnnecessaryShutdown;
@end
/// .m
static mySingleton *sharedInstance;
@implemenation mySingleton
+ (void)startup
{
[self sharedInstance];
}
+ (void)shutdown
{
self.someData = nil;
}
+ (id)sharedInstance
{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
sharedInstance = [[self alloc] init];
});
return sharedInstance;
}
- (instanceType)init
{
self = [super init];
if (self)
{
_someData = [NSObject new];
}
return self;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment