Skip to content

Instantly share code, notes, and snippets.

@wellle
Last active December 19, 2015 09:49
Show Gist options
  • Save wellle/5936304 to your computer and use it in GitHub Desktop.
Save wellle/5936304 to your computer and use it in GitHub Desktop.
Small class that adds itself as observer, but never removes itself again.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// ...
Terminate *terminate = [[Terminate alloc] init];
[terminate release];
return YES;
}
@interface Terminate : NSObject
@end
#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