• 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: How to get strings like <CSSDictionary: 0x126a70> for all objects
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to get strings like <CSSDictionary: 0x126a70> for all objects


  • Subject: Re: How to get strings like <CSSDictionary: 0x126a70> for all objects
  • From: Ken Thomases <email@hidden>
  • Date: Sun, 22 Feb 2009 12:19:47 -0600

On Feb 22, 2009, at 9:02 AM, Jean-Daniel Dupas wrote:

Le 22 févr. 09 à 15:14, Ken Tozier a écrit :

Hi

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 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?

Thanks for any help


Why you don't use the object directly as key instead of a generated string ?
If this is the "copy key" behavior of the dictionary that bother you, you can either use the CoreFoundation API and use kCFTypeDictionaryKeyCallBacks to create your dictionary (warning: do not mix CF and NSDictionary call with a custom key callback, the NSDictionary API may call copy: whatever the callback is).
Else, you can use (as suggested by Andrew) NSHashTable or NSMapTable.

As still another option, which is convenient for Tiger deployment, you can use an NSValue (+[NSValue valueWithNonretainedObject:]) to make the object pointer the key for your dictionary.


Cheers,
Ken

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden


References: 
 >How to get strings like <CSSDictionary: 0x126a70> for all objects (From: Ken Tozier <email@hidden>)
 >Re: How to get strings like <CSSDictionary: 0x126a70> for all objects (From: Jean-Daniel Dupas <email@hidden>)

  • Prev by Date: Small animation inside NSCell (progress bar)
  • Next by Date: Re: NSNotificationCenter : multiple messages sent to the same observer?
  • Previous by thread: Re: How to get strings like <CSSDictionary: 0x126a70> for all objects
  • Next by thread: Re: How to get strings like <CSSDictionary: 0x126a70> for all objects
  • Index(es):
    • Date
    • Thread