Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problems with NSApplication Delegates



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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.