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.
Thanks Joar, John and Chris.
I think I was being "too clever by half" with the whole NSInvocation
thing. I turns out that for what I'm doing, it's easier to just use KVO
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