Problems with NSApplication Delegates
Problems with NSApplication Delegates
- Subject: Problems with NSApplication Delegates
- From: Bruce Truax <email@hidden>
- Date: Sat, 04 Dec 2004 09:19:56 -0500
I have a document based application and I need to use
aaplicationWillTerminate: to clean up some temporary files. My application
has a class called AccosApplication which is a subclass of NSApplication.
@interface AccosApplication : NSApplication
{
IBOutlet id aboutPanel;
}
In the init method of that class I declare the class itself as the delegate:
@implementation AccosApplication
- (id) init
{
[super init];
[self setDelegate: self];
NSLog(@"Application is initializing");
NSLog(@"Delegate set to %@",[[self delegate] description]);
return self;
}
This gets executed an according the log correctly sets itself as the
delegate. I then implement applicationShouldTerminate and
applicationWillTerminate as follows:
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication
*)sender
{
return YES;
}
- (void)applicationWillTerminate:(NSNotification *)aNotification
{
NSLog(@"Application is terminating");
}
When I quit the application using the QUIT menu as defined in the default
app these two methods are never called. I also tried [super
setDelegate:self] with the same results. I am sure I am making an obvious
mistake but it is just not obvious enough for me to see.
Thanks.
Bruce
--
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden