• 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: NSWindowController that closes itself
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSWindowController that closes itself


  • Subject: Re: NSWindowController that closes itself
  • From: "Erik M. Buck" <email@hidden>
  • Date: Tue, 13 Nov 2001 21:08:42 -0600

> I'm writing a NSWindowController subclass (but not one to be used for a
> NSDocument). I've made it the NSWindow delegate for its window as well.
>
> Now, when the user closes the window, being the NSWindow delegate I get
> a windowWillClose, and I handle it by sending a message directly to some
> object and then doing [self autorelease].
>
> Under certain conditions, I would like to initiate the same process
> myself, from within my NSWindowController subclass. I tried [[self
> window] performClose:self], but when I do that, my windowWillClose
> doesn't get called!
>
> Why is that, and what should I do to overcome this?

It is probably that way because if you send a message to close the window
you probably want it to close.

However, if you can send -performClose: to a window then you can write the
following code:

if([[[self window] delegate]
respondsToSelector:@selector(windowWillClose:)])
{
if([[[self window] delegate] windowWillClose:[self window]])
{
[[self window] performClose:self];
}
}
else
{
[[self window] performClose:self];
}


  • Follow-Ups:
    • Re: NSWindowController that closes itself, revisited
      • From: Dan Bernstein <email@hidden>
    • Re: NSWindowController that closes itself
      • From: Dan Bernstein <email@hidden>
    • Re: NSWindowController that closes itself
      • From: "John C. Randolph" <email@hidden>
References: 
 >NSWindowController that closes itself (From: Dan Bernstein <email@hidden>)

  • Prev by Date: Re: CFPreferencesSetValue in pref pane not working if logged in as non-admin
  • Next by Date: Re: NSWindowController that closes itself
  • Previous by thread: NSWindowController that closes itself
  • Next by thread: Re: NSWindowController that closes itself
  • Index(es):
    • Date
    • Thread