Last active
December 16, 2015 21:09
-
-
Save DHowett/5497730 to your computer and use it in GitHub Desktop.
Revisions
-
DHowett revised this gist
May 1, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -17,7 +17,7 @@ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_applicationDidBecomeActive:) name:UIApplicationDidBecomeActiveNotification object:nil]; } - (void)_applicationDidBecomeActive:(NSNotification *)notification { // explode or whatever } @end -
DHowett created this gist
May 1, 2013 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ @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 { // explode or whatever } @end %ctor { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; [[MyAwesomeSingletonPleaseDontNameMeThis sharedInstance] registerForNotifications]; [pool drain]; }