• 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
tag != pointer under GC (was Re: SetControlReference equivalent in NSControl?)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >SetControlReference equivalent in NSControl? (From: email@hidden)
 >Re: SetControlReference equivalent in NSControl? (From: Graham Cox <email@hidden>)
 >Re: SetControlReference equivalent in NSControl? (From: Kevin Elliott <email@hidden>)
 >Re: SetControlReference equivalent in NSControl? (From: Graham Cox <email@hidden>)

  • Prev by Date: Re: SetControlReference equivalent in NSControl?
  • Next by Date: Re: Causing CFLog error messages
  • Previous by thread: Re: SetControlReference equivalent in NSControl?
  • Next by thread: Sourcelist background colors
  • Index(es):
    • Date
    • Thread