Re: SetControlReference equivalent in NSControl?
Re: SetControlReference equivalent in NSControl?
- Subject: Re: SetControlReference equivalent in NSControl?
- From: Graham Cox <email@hidden>
- Date: Thu, 26 Jun 2008 14:39:12 +1000
On 26 Jun 2008, at 6:01 am, Kevin Elliott wrote:
There is no reason to subclass his control to attach an int value
(or more generally to track which instance a particular control
is). See NSControl tag/setTag. They allow you to do exactly what
he wants.
Well, not quite - tags store ints, whereas a Carbon Control refCon is
*typically* used to store a pointer or Handle, so I didn't mention it
to avoid misleading the OP into thinking that tags and refCons were
semantically identical.
Additionally if you want to attach some sort of object (say a string
or something more complex that needs to be retained) see
representedObject/setRepresentedObject. It's part of NSCell not
NSControl, but most of the complex controls have a NSCell subclass
anyway (i.e. an NSButtonCell is attached to every NSButton).
Right, I'd overlooked that one. This sounds much more appropriate.
G.
_______________________________________________
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