NSApplication Bug. Quit doesn't notify windows (& delegates), just kills them.
NSApplication Bug. Quit doesn't notify windows (& delegates), just kills them.
- Subject: NSApplication Bug. Quit doesn't notify windows (& delegates), just kills them.
- From: email@hidden
- Date: Tue, 17 Jul 2001 12:18:28 -0700
Hi there,
I think this may be related to the previous "bug" I posted about in
which I noted that if you have a custom view in a window when the
application closes (or the window is closed), the dealloc method is NOT
called for the view; or at least I can't print via NSLog or stop at a
breakpoint there.
Now I moved to the next example in the Learning Cocoa book - Delegates.
So I've installed a window delegate and it all seems work work fine, or
so it appears.
I got my "save changes" dialog working, and then switched to using a
sheet coming up and it works fine, or so it appears.
Here's the Bug:
1) in my window delegate:
windowShouldClose IS called if I hit the close dot (red dot) in the
window title bar.
windowShouldClose IS called if I select the "Close" command in the
File menu.
Here's the BUG/Design flaw:
windowShouldClose IS NOT CALLED if I select "Quit" from the
application menu.
If I quit an application, shouldn't NSApplication attempt to close each
window and have the window still call the delegate with the
windowShouldClose message? If it doesn't do this then the utility of
this delegate message to prompt for the "save changes" confirmation is
100% nothing; it's utterly useless because you have to implement some
other mechanism anyway.
This has got to be a bug. right?
Anyone on the cocoa team care to respond? (and add it to the bug list
if you agree, please).
peace,
Tyler
P.S.:
On Monday, July 16, 2001, at 09:35 PM, tyler wrote:
2) If I set breakpoints in the DotView custom View I see that several
methods are called twice (awakeFromNib and initWithFrame in
particular). It appears the the "self" value in the debugger has
changed so I'm guessing that one call is for the "proxy" object created
due to the nib (not that I really understand what that means, just read
it somewhere), and one is the real object that I defined and that the
proxy instantiates (???).
---
I'm not seeing this.
---
Interesting. I wonder what I did differently to get this to happen.
Something in how I interacted with IB I suspect...
Oh, I figured this previously posted question out: I had "Instantiated"
my DotView class via the Classes menu. As it turns out, it seems like
doing this is only necessary for classes that do NOT appear in the
window (or menu?), and once you take the CustomView and select
CustomClass == DotView you have effectively instantiated it and so do
NOT need to instantiate it manually. Makes sense when you think about
the fact that IB is not actually saving a datastructure defining the UI
(like ResEdit or Resorcerer), but instead actually flattening the
objects themselves for later reanimation. Very cool.