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

case-insensitive NSDictionary


  • Subject: case-insensitive NSDictionary
  • From: Roland King <email@hidden>
  • Date: Mon, 16 Mar 2009 22:02:33 +0800

Any good ideas for doing a key-case-insensitive NSDictionary of NSString to NSString? I have some HTTP headers I want to stick in a dictionary and look up later. HTTP headers have case-insensitive keys.

I could upper, or lowercase the key before putting it in the NSMutableDictionary, but that means I lose the original case of the key (I probably shouldn't care but I hate throwing away information), and any user of my class has to know to upper or lowercase the key before looking it up, or else I don't expose the dictionary at all and just give lookup methods which hide the details. That's a shame, I wanted the user to have access too all the keys if they wanted it and wanted to just make the NSDictionary available as a property.

I could make a case-insensitive string, but subclassing NSString wasn't in my plans for Monday evening, or Tuesday and the user still has to make the same NSCaseInsensitiveString() object to look up the key.

I could make a case-insensitive version of NSMutableDictionary which ... oh that's worse, forget I even said that.

I think I'm going to lower-case on insert and tell the user the NSDictionary of headers has lower-case keys but .. is there something obvious I missed? _______________________________________________

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: case-insensitive NSDictionary
      • From: Jeremy Pereira <email@hidden>
    • Re: case-insensitive NSDictionary
      • From: "Adam R. Maxwell" <email@hidden>
    • Re: case-insensitive NSDictionary
      • From: Dave DeLong <email@hidden>
  • Prev by Date: Re: Adding multiple NSTextViews inside one NSScrollView
  • Next by Date: Re: case-insensitive NSDictionary
  • Previous by thread: Re: Renaming a file
  • Next by thread: Re: case-insensitive NSDictionary
  • Index(es):
    • Date
    • Thread