Last active
December 19, 2015 09:49
-
-
Save wellle/5936304 to your computer and use it in GitHub Desktop.
Small class that adds itself as observer, but never removes itself again.
This file contains 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
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { | |
// ... | |
Terminate *terminate = [[Terminate alloc] init]; | |
[terminate release]; | |
return YES; | |
} |
This file contains 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 Terminate : NSObject | |
@end |
This file contains 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
#import "Terminate.h" | |
@implementation Terminate | |
- (id)init { | |
self = [super init]; | |
if (self == nil) return nil; | |
[[NSNotificationCenter defaultCenter] addObserver:self | |
selector:@selector(appWillTerminate) | |
name:UIApplicationWillTerminateNotification | |
object:nil]; | |
return self; | |
} | |
-(void)appWillTerminate { | |
NSLog(@"-[Terminate terminate]"); | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment