Re: How to add delegate to my application
Re: How to add delegate to my application
- Subject: Re: How to add delegate to my application
- From: Robert Goldsmith <email@hidden>
- Date: Tue, 18 Sep 2001 00:03:55 +0100
Hello all,
I want my application do something before it quit. I add function
applicationWillTerminate to Controller.m in my application. But it
seems the application didn't receive the notification and never run
this function. If I need set other things to get this function to be
valid?
As you correctly assume, you need to delegate the method. However,
you also need to tell your NSApplication instance what class instance
will be it's delegate. To do this you can use Interface Builder.
If the instance of the class you are using as the delegate is not
present in the window in Interface Builder that has NSApplication and
First Responder etc, add it. To do this, select read file from the
classes menu and open the header file for the class then use create
instance. In small apps, simply put the delegation code in the main
instance and you dont have to do this bit.
Control click/drag from your instance to the NSApplication object -
as if you were linking outlets / actions.
Select delegate in the list for NSApplication (in the connections
panel of the object info window) and select connect.
This should setup your instance as the NSApplication delegate :)
This threw me for a bit as i expected the answer to be in code - not
interface builder ! :)
Robert
ps. this is from memory and I only learnt / used it for the first
time recently so sorry if some of the info is slightly wrong. You get
the idea anyhow <g>
--
Please note the new email address:
email@hidden
--
Please note the new email address:
email@hidden