Re: Is the "id" type an immovable pointer? Or a movable handle
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: Joar Wingfors <email@hidden>
- Date: Thu, 1 Feb 2007 00:56:08 +0100
On Feb 1, 2007, at 12:06 AM, Ken Tozier wrote:
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.
How many are "a bunch"? I can't really think of a typical scenario
for using NSInvocations where the overhead of an equal number of
UUIDs would matter.
That said, the address of an object doesn't change so you could wrap
it in a NSValue (see: -[NSValue valueWithNonretainedObject:]) and use
that if you would want to.
The problems that John mentioned are most likely not an issue in your
case, as your invocation targets are of your own custom classes (my
conclusion, as you mentioned the possibility of using a shared base
class), and as such their create / copy behaviour are under your
control.
j o a r
_______________________________________________
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