• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Problems with NSApplication Delegates
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Problems with NSApplication Delegates
      • From: j o a r <email@hidden>
  • Prev by Date: Re: Legality of using Apple resources / icons?
  • Next by Date: Re: compositing views into one window
  • Previous by thread: Re: Application crash in -[NSViewHierarchyLock lockForWriting]
  • Next by thread: Re: Problems with NSApplication Delegates
  • Index(es):
    • Date
    • Thread