tag != pointer under GC (was Re: SetControlReference equivalent in NSControl?)
tag != pointer under GC (was Re: SetControlReference equivalent in NSControl?)
- Subject: tag != pointer under GC (was Re: SetControlReference equivalent in NSControl?)
- From: Chris Hanson <email@hidden>
- Date: Wed, 25 Jun 2008 22:11:18 -0700
On Jun 25, 2008, at 9:39 PM, Graham Cox wrote:
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.
Also, it's important to point out that Cocoa and Objective-C will
treat a tag as an integer, period, rather than as a pointer to an
object. They may be equivalent under non-GC, but under Objective-C
Garbage Collection the collector *will* collect an object whose only
remaining references are in integers like control tags.
If you want to refer to an object, you should really refer to it via a
variable of appropriate type.
-- Chris
_______________________________________________
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