• 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: Uli Kusterer <email@hidden>
  • Date: Thu, 1 Feb 2007 09:14:20 +0100

Am 01.02.2007 um 00:06 schrieb Ken Tozier:
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?

The Cocoa APIs don't generally use Handles. Handles are a classic MacOS thing. But even if they were, a Handle is a pointer that points to the movable "actual pointer", so the Handle itself will never change, only the pointer it points to. So, it doesn't matter. If two pointers or Handles point to the same object, they'll be the same and stay that way for the lifetime of the object. If they point to two different objects they'll be different (but as John wrote, if you "copy" an object, you might get back the same object, so of course the pointer will be the same).


But keep in mind that you have to delete your dictionary entries after an object is released. Once an object has been released, the memory it used to occupy may get re-used for another object, so you could theoretically create an NSInvocation, release it, create a second one, and that second one could have the same address as the first.

Cheers,
-- M. Uli Kusterer
http://www.zathras.de



_______________________________________________

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


  • Next by Date: Re: Please can any one sugest or send me Email validation code.
  • Next by thread: Re: Is the "id" type an immovable pointer? Or a movable handle
  • Index(es):
    • Date
    • Thread