• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSApplication callback of some sort?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Prev by Date: [q] scriptSuite conflict problems (code included)
  • Next by Date: Re: Creating PDF from a view with custom bounds
  • Previous by thread: Re: NSApplication callback of some sort?
  • Next by thread: Re: NSApplication callback of some sort?
  • Index(es):
    • Date
    • Thread