David Casti:
> The Cocoa documentation says I should become a delegate for
> applicationWillTerminate, but I've been unable to figure out how to do
> this.
Taking the standard Python template Project as an example, you can
just add this method to your MyAppDelegate class:
def applicationWillTerminate_(self, aNotification):
NSLog( "Application will terminate." )
much like this (existing) one:
def applicationDidFinishLaunching_(self, aNotification):
NSLog( "Application did finish launching." )
The first method will be called when you type Cmd-Q or click on the
Quit menu entry. Instead of calling NSLog() you can do whatever you
need to. With aNotification.object() you should get the NSApp object,
I beliebe.
You can also register an object to observe equivalent "notifications"
posted by the NSApp object, in this case it is "NSApplicationWill\
TerminateNotification" using the class named NSNotificationCenter.
I tried that before and it works.
Regards,
Dinu
--
Dinu C. Gherman
......................................................................
"It is by the goodness of God that in our country we have these three
unspeakably precious things: freedom of speech, freedom of conscience,
and the prudence to practice neither." (Mark Twain)
|