• 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: Newbie: Referencing Objects
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Newbie: Referencing Objects


  • Subject: Re: Newbie: Referencing Objects
  • From: Nick Zitzmann <email@hidden>
  • Date: Sun, 26 Oct 2008 12:38:40 -0600


On Oct 25, 2008, at 11:20 AM, john fogg wrote:

I create a Button and in the course of that I set a "target:" and an
"action:". Unlike any and all of the examples I found on the web and
on Apple's site I don't want the message sent to my current object, so
I don't want "target:self" but another object I created elsewhere from
another class.

How do I do that?


Call -setTarget: on the button with a pointer to the other object, like this: (warning, written in Mail, untested, use at your own risk, etc.)

---
NSButton *button;	// initialize this elsewhere
MyWonderfulObject *otherObject;	// ditto above

[button setTarget:otherObject];
---

Or, if you're targeting Leopard & later only:

---
NSButton *button;
MyWonderfulObject *otherObject;

button.target = otherObject;
---

Nick Zitzmann
<http://www.chronosnet.com/>



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Newbie: Referencing Objects (From: "john fogg" <email@hidden>)

  • Prev by Date: Callback for when a window from another app is moved
  • Next by Date: Re: Newbie: Referencing Objects
  • Previous by thread: Newbie: Referencing Objects
  • Next by thread: Re: Newbie: Referencing Objects
  • Index(es):
    • Date
    • Thread