[comp.sys.next] help on delegates

u-sgreen%peruvian.utah.edu@cs.utah.edu (Scott Greenman) (09/14/90)

I am a new NeXT programmer and I have a few questions about delegates (in
particular, Application delegates):

1)  Is it correct that I can put any method in my delegate definition,
    then send a message to NXApp with that method name and it will get
    executed?

2)  Is it possible for the delegate to override a method that the object
    it is a delegate for normally responds to?  If so, is there any way
    for the delegate to execute the method defined by the object it is a
    delegate for?

What I'm trying to do is use a delegate of an Application to do two things:
a) hold global variables and have methods to query or set these variables
b) execute methods of another object when the application first starts and
   just before it quits.

In relation to b above, how can I send messages to an object that is
instantiated in IB and so loaded with the "LoadNibSection" command?
Do I set up an outlet from the class that is the delegate?

Thanks for any help.

Scott Greenman
Univ of Utah

moose@svc.portal.com (09/14/90)

In article <1990Sep13.145805.1776@hellgate.utah.edu> u-sgreen%peruvian.utah.edu@cs.utah.edu (Scott Greenman) writes:
>I am a new NeXT programmer and I have a few questions about delegates (in
>particular, Application delegates):

Welcome aboard.

>
>1)  Is it correct that I can put any method in my delegate definition,
>    then send a message to NXApp with that method name and it will get
>    executed?

No, just the methods specified in the manuals.

>
>2)  Is it possible for the delegate to override a method that the object
>    it is a delegate for normally responds to?  If so, is there any way
>    for the delegate to execute the method defined by the object it is a
>    delegate for?

No, but the answer to this was dependant on the first one.

>
>What I'm trying to do is use a delegate of an Application to do two things:
>a) hold global variables and have methods to query or set these variables
>b) execute methods of another object when the application first starts and
>   just before it quits.

You are probably better off just subclassing the Application and making that
your file owner.  NXApp will return your subclass instead of an Application
Object.  Then you can do what you want. 

If you really want delegation, then you can use [[NXApp delegate] <<whatever>>]
to do most of what you want.  I really recommend subclassing the Application.

-- 
Michael Rutman				|	moose@svc.portal.com
Cubist					|	makes me a NeXT programmer
Software Ventures			|	That's in Berkeley
smile, you're on standard disclaimer	|	<fill in with cute saying>