• 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: NSDictionary trouble
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: NSDictionary trouble


  • Subject: RE: NSDictionary trouble
  • From: Kirk Kerekes <email@hidden>
  • Date: Tue, 19 Jan 2010 12:46:07 -0600

> I wish NSDictionary (NSMutableDictionary actually) could handle
> arbitrary mappings of one type of object to another, without copying
> the keys.  A string makes a good key most of the time but what about
> the case where you want to do the reverse mapping, to find the string
> which you have associated with a particular object?  I'm accustomed to
> things like Qt and Java where hashtables can contain anything for both
> key and value.  Is there an alternative which does work that way?  I
> didn't try CFDictionary yet; is that appropriate for an iPhone app?

NSDictionary will use almost any object as a key:

From the docs:
"In general, a key can be any object (provided that it conforms to the NSCopying protocol...)"

 -- and if it is an immutable object, that -copy is just a -retain.

Only if you want to use KVC with the NSDictionary to the keys need to be strings.

_______________________________________________

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

  • Follow-Ups:
    • Re: NSDictionary trouble
      • From: Jens Alfke <email@hidden>
  • Prev by Date: Re: NSDictionary trouble
  • Next by Date: Asynchronous IO lags at close
  • Previous by thread: Re: NSDictionary trouble
  • Next by thread: Re: NSDictionary trouble
  • Index(es):
    • Date
    • Thread