Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSApplication callback of some sort?



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) :)




Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.