• 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: Chris Suter <email@hidden>
  • Date: Thu, 1 Feb 2007 10:51:38 +1100


On 01/02/2007, at 10:06 AM, 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.

Why not simply use the id as the key to the dictionary?

If you're worried about the fact that the keys are copied, I believe you can get a dictionary where it's not copied by using NSMapTable, NSHashTable or CFDictionary functions.

The danger with packaging an id in an NSNumber is that the system doesn't know they are pointers which may become an issue with garbage collection. If you have to package pointers, you should probably use + [NSValue valueWithPointer:].

- Chris

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

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: Re: Subclass observers on dealloc
  • Next by Date: Re: Is the "id" type an immovable pointer? Or a movable handle
  • Previous by thread: Re: 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