Re: NSApplication callback of some sort?
Re: NSApplication callback of some sort?
- Subject: Re: NSApplication callback of some sort?
- From: "Mike Vannorsdel" <email@hidden>
- Date: Wed, 18 Jul 2001 22:32:35 -0600
Basically you do two things. First you set your object as NSApp's
delegate:
[NSApp setDelegate:self];
Do this somewhere in your object's initialization. Then you implement
the delegate method(s) you want to use.
- (void)applicationWillTerminate:(NSNotification *)aNotification
{
//do stuff
}
Just add this method in your object class's implementation and insert
the code you want executed when this method is called. Some delegate
methods have return types which will allow you some control over NSApp.
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication
*)sender
{
if(someCondition)
return NSTerminateCancel;
else
return NSTerminateNow;
}
This will allow you to stop the application from quitting.
On Wednesday, July 18, 2001, at 10:16 PM, Graham Wihlidal wrote:
Ok, are there any examples on Apple's site or the Developer examples
that illustrate using NSApplication delegates? I am really new to this
and haven't used them yet (obviously) :)