Re: Newbie: Referencing Objects
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