• 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: Responding from a delegate?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Responding from a delegate?


  • Subject: Re: Responding from a delegate?
  • From: Kay Roepke <email@hidden>
  • Date: Thu, 15 Apr 2004 20:19:58 +0200

On 15. Apr 2004, at 16:55 Uhr, Sam Thorne wrote:

Hello list,

A total newbie question this; I'm coming from a ECMA-262 & Lingo background so keep it simple for stupid (me)!

I've been playing around with adding NSToolbar to a document window in a multi-doc app; no problem there the toolbar appears.
The problem is the toolbar methods are delegated, as I was following a tutorial that recommended doing so.

What I can't get my head round is how to respond from the delegate object back to the delegator, specifically one of the IBActions is meant to open a drawer in the window of the window controller that is the delegator.
Do I have to set an instance variable referring back to the delegator in the delegate? This seems a bit messy.

The action methods are declared like this:

-(IBAction)myAction:(id)sender;

So the action's name is myAction, the IBAction simply tells the Interface Builder that this is an action (and also
tells the compiler that this method does not return any value, because IBAction is actually defined as void)
and most importantly (for this question) is:
The parameter (id)sender (read: any kind of object, available in your method as 'sender') is set to the object
which called your action.

So if you in turn want to have information from the sender, well ask sender. Like in:

-(IBAction)myAction:(id)sender
{
NSLog(@"intValue of sender %d:\n", [sender intValue]);
}

Kay

P.S.: On second thought, do you really mean an action of one of you interface elements, or do you mean an actual delegate method?
Could you provide some source code which gives you trouble?
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: Responding from a delegate?
      • From: Sam Thorne <email@hidden>
References: 
 >Responding from a delegate? (From: Sam Thorne <email@hidden>)

  • Prev by Date: C++ templates?
  • Next by Date: Re: New book on its way!!!
  • Previous by thread: Re: Responding from a delegate?
  • Next by thread: Re: Responding from a delegate?
  • Index(es):
    • Date
    • Thread