Re: A few basic questions
Re: A few basic questions
- Subject: Re: A few basic questions
- From: "Nathan V. Roberts" <email@hidden>
- Date: Thu, 21 Jun 2001 18:05:39 -0500
Just to say, I've figured out #1 and #2. My apologies for asking
questions I managed on my own--I'd not been getting anywhere on these
for a while, and I guess articulating the questions for the list gave
me new insight as far as what to try. In any case, here's what I
found to work:
For #1 (windowWillClose being called too many times), the
explanation/solution goes something like this: I kept my NSWindow
ref in my NSWindowController subclass in a "window" variable, which I
expected the nib loader to set automatically. But the nib loader
looks first for an accessor method that looks like setVariable(), and
if that's available calls it. So it found and called setWindow--in
the superclass. My window was never being set in the first place.
So I implement setWindow() in my subclass, and have it call setWindow
of the superclass, and now things work as I would
expect--windowWillClose() is called exactly once per window.
The answer to #2 (autosave) is that autosave is not automatically
removed by the NSWindowController going away. Call the class method
NSWindow.removeFrameUsingName() to do this.
I'd still be interested in an answer to #3, the AppleScript question.
Nathan Roberts
1. Windows-- I'm subclassing NSWindowController, and implement the
WindowWillClose method--I want the window and its controller to both
go away if the window is closed. Here's the code for that:
public void windowWillClose(NSNotification aNotification) {
dsTimerArray.remove(this.number.intValue());
window = null;
}
(The only reference that I have to the windowController is held in
dsTimerArray.)
If the user closes a window during execution, then quits, what ends
up happening is that the WindowWillClose method is called twice for
that window--once on close, once on quit. My guess is that my
problem is failing to ensure the Window Controller's deallocation,
and that the app still thinks the Window Controller is valid--how do
I make sure the Window Controller goes away?
2. Window autosave--this is probably related to #1, but I want to
forget about the autosave after a window is closed by the user.
Will this happen automatically if the NSWindowController actually
gets unloaded before the app terminates?