Last active
December 16, 2015 21:09
-
-
Save DHowett/5497730 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
@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]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That's an interesting naming scheme...