• 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: Is the "id" type an immovable pointer? Or a movable handle
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is the "id" type an immovable pointer? Or a movable handle


  • Subject: Re: Is the "id" type an immovable pointer? Or a movable handle
  • From: John Stiles <email@hidden>
  • Date: Wed, 31 Jan 2007 15:20:01 -0800

Well, they're definitely pointers and not handles.

I don't think there's any guarantee that they're unique, though. They usually will be unique. But for instance, if you use -copy to duplicate an immutable NSObject, the copy will probably be the same object with its refcount bumped. Or if you get two NSNumbers, both representing zero, you will probably get the same pointer back both times (since this is such a common object, the system just has one of them and gives everyone the same object; again, it's just a refcounting game). I think NSColor has some similar optimizations as well.

If your concern is just that the id could become invalid at some later point, no, that can't happen as long as it is appropriately retained. Even if they were secretly implemented as handles, it would still be OK. Think about it for a while and that should be clear :)


On Jan 31, 2007, at 3:06 PM, Ken Tozier wrote:

Hi

I'm creating a bunch of NSInvocations and want to store them in a dictionary with a key that uniquely identifies the invocation target. I checked the "Objective C runtime" documentation and it doesn't appear that NSObjects have unique identifiers. I thought of adding a uuid property to a base class but uuids are 128 bytes so I was wondering, if objects don't move around in memory after allocation, I could just package the id to an NSNumber and use that for the key.

Anyone know if ids are pointers or handles?

Thanks

Ken
_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
40blizzard.com


This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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: 
 >Is the "id" type an immovable pointer? Or a movable handle (From: Ken Tozier <email@hidden>)

  • Prev by Date: Is the "id" type an immovable pointer? Or a movable handle
  • Next by Date: Re: NSButton Text Color?
  • Previous by thread: Is the "id" type an immovable pointer? Or a movable handle
  • Next by thread: Re: Is the "id" type an immovable pointer? Or a movable handle
  • Index(es):
    • Date
    • Thread