On 22 Feb 09, at 06:14, Ken Tozier wrote:
I need to get unique identifiers for all objects I'm passed for use
as keys in an NSMutableDictionary. I tried using hash but I don't
know if that would really be unique.
It isn't. The only requirement for -[NSObject hash] is that two
objects which are considered equal must have the same hash. It's
perfectly valid (albeit silly) to implement the hash method as
returning a constant value.
It seems like the console printout for classes with no "description"
method would be perfect. I know how to get the class but how to get
the object address in hex? Here's a partial solution
[NSString stringWithFormat: @"<%@ %???>", [[someObject class]
description], someObject];
Is there a format code that would give me the address in hex?
@"%p" will give a string representation of the address. However, if
you're targeting 10.5 or later, you should probably consider
NSMapTable instead - it implements this functionality for you without
the overhead of generating string keys.
_______________________________________________
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
Please 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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to arch...@mail-archive.com