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

Re: NSWindowWillCloseNotification problem


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

Amazing what posting to the list does for problem solving skills...

I figured it out as soon as I posted it - I was registering multiple times for the notification, so I was getting multiple notifications. It obviously doesn't check whether you have already registered the same thing. I moved it to my awakeFromNib, and it works fine.

Gideon

On Sunday, December 9, 2001, at 12:12 AM, Gideon King wrote:

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.


References: 
 >NSWindowWillCloseNotification problem (From: Gideon King <email@hidden>)

  • Prev by Date: Re: NSWindowWillCloseNotification problem
  • Next by Date: %* format doesn't work in NSLog
  • Previous by thread: Re: NSWindowWillCloseNotification problem
  • Next by thread: Re: NSWindowWillCloseNotification problem
  • Index(es):
    • Date
    • Thread