Re: case-insensitive NSDictionary

2009-03-16 Thread Roland King
That I didn't know - thanks, I'll make sure and combine the values from repeated keys with commas. Thanks also for all the other suggestions. Given this latest point, subclassing NSMutableDictionary seems to be a good way to go as I can adjust addObjectForKey to deal with the repeated key case

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
When I had to solve the exact same problem, I created a new class that wrapped the NSString as an ivar and defined my own hash and isEqual methods (which both used the corresponding methods on a lower case version of the string) and implemented NSCopying (easy because my class was immutable

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 d

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 >> look up later. HTTP headers hav

Re: case-insensitive NSDictionary

2009-03-16 Thread Roland King
thank you - I really must think about searching the CF-equivalent to the NS classes, there is a lot of extra stuff I have no idea at all exists. This is exactly what I need. On Mar 16, 2009, at 10:26 PM, Adam R. Maxwell wrote: On Mar 16, 2009, at 7:02 AM, Roland King wrote: Any good ideas

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 call

Re: case-insensitive NSDictionary

2009-03-16 Thread Dave DeLong
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. Dave Sent from my iPod On Mar 16, 2009, at 8:02 AM, Roland King wrote: Any good ideas for doing a key-case-insensitiv