A few basic questions
A few basic questions
- Subject: A few basic questions
- From: "Nathan V. Roberts" <email@hidden>
- Date: Thu, 21 Jun 2001 12:28:58 -0500
Hi,
Just programming in Cocoa for the first time, and have a few basic
questions. I'm working in Java.
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?
3. AppleScript--I've read the basic docs for adding Applescript
support, but I'm a little mystified as to where the top-level objects
are supposed to reside. Say I want to expose a specialObject to
AppleScript. I understand that I'll want accessor methods
specialObject() and setSpecialObject(), but where do I place them?
In the app delegate? I've played with this, and haven't been able to
get it working, but the problem may also lie in my script suite or
terminology.
Thanks in advance for your help.
Nathan Roberts