Re: case-insensitive NSDictionary

2009-03-16 Thread Roland King
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 me

Re: case-insensitive NSDictionary

2009-03-16 Thread Michael Vannorsdel
You could also just make your own wrapper class for NSDictionary with the usual set/remove methods and sub the key in the wrapper. On Mar 16, 2009, at 9:37 AM, Bill Bumgarner wrote: Wile certainly a creative solution, this suggestion is an 11 on the scale of 1 to 10 of bad ideas. Even if

Re: case-insensitive NSDictionary

2009-03-16 Thread Jeremy Pereira
dictionary must be NSMutableArrays of strings. On 16 Mar 2009, at 14:02, Roland King wrote: 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

Re: case-insensitive NSDictionary

2009-03-16 Thread Sherm Pendley
On Mon, Mar 16, 2009 at 2:20 PM, Stuart Malin wrote: > > On Mar 16, 2009, at 7:55 AM, Sherm Pendley > wrote: > > Beats me - I've often wondered the same thing. All you need to do is > implement the required primitive methods. What's so hard about that? > > > Question from a non-expert: > > How d

Re: case-insensitive NSDictionary

2009-03-16 Thread Michael Ash
On Mon, Mar 16, 2009 at 2:20 PM, Stuart Malin wrote: > > On Mar 16, 2009, at 7:55 AM, Sherm Pendley  wrote: > > On Mon, Mar 16, 2009 at 12:03 PM, Michael Ash wrote: > > > Why does everybody think that subclassing a class cluster is hard? > > > Beats me - I've often wondered the same thing. All yo

Re: case-insensitive NSDictionary

2009-03-16 Thread Bill Bumgarner
On Mar 16, 2009, at 11:20 AM, Stuart Malin wrote: How does one know just which methods are "required primitive" methods for some class? Is that discernible from documentation? Header file? They are documented, but the header files also split the primitives from the rest. Look at NSString

Re: case-insensitive NSDictionary

2009-03-16 Thread Stuart Malin
On Mar 16, 2009, at 7:55 AM, Sherm Pendley wrote: On Mon, Mar 16, 2009 at 12:03 PM, Michael Ash wrote: Why does everybody think that subclassing a class cluster is hard? Beats me - I've often wondered the same thing. All you need to do is implement the required primitive methods. W

Re: case-insensitive NSDictionary

2009-03-16 Thread Sherm Pendley
On Mon, Mar 16, 2009 at 12:03 PM, Michael Ash wrote: > > Why does everybody think that subclassing a class cluster is hard? Beats me - I've often wondered the same thing. All you need to do is implement the required primitive methods. What's so hard about that? sherm-- -- Cocoa programming i

Re: case-insensitive NSDictionary

2009-03-16 Thread Bill Bumgarner
On Mar 16, 2009, at 8:57 AM, Paul Sanders wrote: Why not just subclass NSDictionary to do this? Seems straightforward to me. That would certainly be viable. I made a different assumption than you; namely that the strings should continue to hash and isEqual: as case insensitive outside o

Re: case-insensitive NSDictionary

2009-03-16 Thread Paul Sanders
> Why not just subclass NSDictionary to do this? Seems straightforward to > me. > What is swizzling? Ah, OK, having just read Michael's post I now understand what the problem is. Sorry about that, the solution proposed is otherwise admirably simple. Rgds - Paul Sanders.

Re: case-insensitive NSDictionary

2009-03-16 Thread Michael Ash
On Mon, Mar 16, 2009 at 11:52 AM, Jean-Daniel Dupas wrote: > > Le 16 mars 09 à 16:37, Bill Bumgarner a écrit : > >> On Mar 16, 2009, at 7:05 AM, Dave DeLong wrote: >>> >>> You could swizzle the objectForKey: and setObject:forKey: methods with >>> your own that just lowercase the passed in string a

Re: case-insensitive NSDictionary

2009-03-16 Thread Paul Sanders
>> You could swizzle the objectForKey: and setObject:forKey: methods >> with your own that just lowercase the passed in string and then call >> the actual methods with the new key. > Wile certainly a creative solution, this suggestion is an 11 on the > scale of 1 to 10 of bad ideas. Even if it w

Re: case-insensitive NSDictionary

2009-03-16 Thread Jean-Daniel Dupas
Le 16 mars 09 à 16:37, Bill Bumgarner a écrit : On Mar 16, 2009, at 7:05 AM, Dave DeLong wrote: You could swizzle the objectForKey: and setObject:forKey: methods with your own that just lowercase the passed in string and then call the actual methods with the new key. Wile certainly a crea

Re: case-insensitive NSDictionary

2009-03-16 Thread Michael Ash
On Mon, Mar 16, 2009 at 11:07 AM, Dave DeLong wrote: > As a followup, I tried doing this just now, and then realized that I'd > forgotten that NSDictionary is a class cluster, and so it would probably > take a lot of gentle massaging to get this method to work correctly. > > Using the callback wou

Re: case-insensitive NSDictionary

2009-03-16 Thread Bill Bumgarner
On Mar 16, 2009, at 7:05 AM, Dave DeLong wrote: You could swizzle the objectForKey: and setObject:forKey: methods with your own that just lowercase the passed in string and then call the actual methods with the new key. Wile certainly a creative solution, this suggestion is an 11 on the sc

Re: case-insensitive NSDictionary

2009-03-16 Thread Dave DeLong
As a followup, I tried doing this just now, and then realized that I'd forgotten that NSDictionary is a class cluster, and so it would probably take a lot of gentle massaging to get this method to work correctly. Using the callback would probably be easier. =) Dave On Mar 16, 2009, at 8:

Re: case-insensitive NSDictionary

2009-03-16 Thread Adam R. Maxwell
On Mar 16, 2009, at 7:37 AM, Michael Ash wrote: On Mon, Mar 16, 2009 at 10:26 AM, Adam R. Maxwell wrote: On Mar 16, 2009, at 7:02 AM, Roland King wrote: 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

Re: case-insensitive NSDictionary

2009-03-16 Thread Michael Ash
On Mon, Mar 16, 2009 at 10:26 AM, Adam R. Maxwell wrote: > > On Mar 16, 2009, at 7:02 AM, Roland King wrote: > >> 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 >>

Re: case-insensitive NSDictionary

2009-03-16 Thread Roland King
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. Use a CFDictionary with custom key callbacks that have a case- insensitive hash and equality function

Re: case-insensitive NSDictionary

2009-03-16 Thread Adam R. Maxwell
On Mar 16, 2009, at 7:02 AM, Roland King wrote: 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. Use a CFDictionary with custom key

Re: case-insensitive NSDictionary

2009-03-16 Thread Dave DeLong
-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

case-insensitive NSDictionary

2009-03-16 Thread Roland King
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