Skip to content

Instantly share code, notes, and snippets.

@DHowett
Last active Dec 16, 2015
Embed
What would you like to do?
@interface MyAwesomeSingletonPleaseDontNameMeThis: NSObject
+ (id)sharedInstance;
- (void)registerForNotifications;
@end
@implementation MyAwesomeSingletonPleaseDontNameMeThis
+ (id)sharedInstance {
static id _sh;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_sh = [[self alloc] init];
});
return _sh;
}
- (void)registerForNotifications {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_applicationDidBecomeActive:) name:UIApplicationDidBecomeActiveNotification object:nil];
}
- (void)_applicationDidBecomeActive:(NSNotification *)notification {
// explode or whatever
}
@end
%ctor {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[[MyAwesomeSingletonPleaseDontNameMeThis sharedInstance] registerForNotifications];
[pool drain];
}
@rmsy
Copy link

rmsy commented May 1, 2013

@interface MyAwesomeSingletonPleaseDontNameMeThis: NSObject

That's an interesting naming scheme...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment