Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

mathcolo

macrumors 6502a
Original poster
Sep 14, 2008
860
16
Boston
Hi there :D

In my application, I have a class. It's just a class that does some other stuff, but along with that other stuff, I need it to respond as the application delegate to the applicationWillTerminate or applicationShouldTerminate methods. Unfortunately, even after having set the application delegate via. code and Interface Builder, neither one of those methods work.

I'm setting the application delegate in the awakeFromNib method of this class like this:

Code:
[[NSApplication sharedApplication] setDelegate:self];

And I'm using the methods like this:

Code:
- (void)applicationShouldTerminate:(NSNotification *)aNotification {
NSLog(@"It'd be great if this actually ran...");
}

Also, that method was placed in the header file. I don't know if that matters or not.

Any help would be appreciated! Thanks.
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
And I'm using the methods like this:

Code:
- (void)applicationShouldTerminate:(NSNotification *)aNotification {
NSLog(@"It'd be great if this actually ran...");
}
That's the wrong method implementation. While it might still get called, it's wrong. The correct one is this:
Code:
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender

Also, that method was placed in the header file. I don't know if that matters or not.
Most likely you put it in the wrong place. It should go where all your other methods go..
 

mathcolo

macrumors 6502a
Original poster
Sep 14, 2008
860
16
Boston
I sincerely apologize for not realizing that the class where this is all in is instantiated in another nib, and not the main one. Therefore, it doesn't get run until another window is shown. I never opened that window while I was testing this.

My bad, but still thanks for your assistance kainjow!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.