• 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
NSWindowWillCloseNotification problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSWindowWillCloseNotification problem


  • Subject: NSWindowWillCloseNotification problem
  • From: Gideon King <email@hidden>
  • Date: Sun, 9 Dec 2001 00:12:25 +0800

I have a window that I display when the user presses a button, and when they close the window, I want to be notified so that I can do some stuff when they close the window. The first time I do this, it works fine, but the next time it fires the close notification twice, and then 3 times etc.

I have stripped it back to something really simple:

// Called when I press the button
- (IBAction)doIt:(id)sender
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(itWillClose:) name:NSWindowWillCloseNotification object:otherWindow];

[otherWindow makeKeyAndOrderFront:self];
NSLog(@"Displayed");
}

// Called when I close the window
- (void)itWillClose:(NSNotification *)notification
{
NSLog(@"Closed");
}

The output for multiple times opening and closing the window is:
Displayed
Closed
Displayed
Closed
Closed
Displayed
Closed
Closed
Closed
...
Anyone have any idea why this might be happening? Any way around this?

TIA

Gideon.


  • Follow-Ups:
    • Re: NSWindowWillCloseNotification problem
      • From: Jeff Gilbert <email@hidden>
    • Re: NSWindowWillCloseNotification problem
      • From: Gideon King <email@hidden>
    • Re: NSWindowWillCloseNotification problem
      • From: John Hörnkvist <email@hidden>
  • Prev by Date: NSOpenPanel and ".app" fileType and aliases
  • Next by Date: Re: NSWindowWillCloseNotification problem
  • Previous by thread: Re: NSOpenPanel and ".app" fileType and aliases
  • Next by thread: Re: NSWindowWillCloseNotification problem
  • Index(es):
    • Date
    • Thread