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 it would work, which it won't because NSDictionary -- as noted later -- is a class cluster.

The swizzling would change the behavior of all NSDictionary instances. I'd wager a rather large sum of money that the rest of the AppKit, Foundation, CoreFoundation, CoreData, and any other framework that uses NSDictionary instances would have at least one case where making all strings suddenly case insensitive as keys would behave rather badly.

Simple rule:  Do Not Swizzle in Production Code.

A solution to the OP's problem is to create a subclass of NSObject that contains an NSString, implements the appropriate NSString like get/set methods, and implements -hash and -isEqual: based on the - lowercase string of the contained string. Make sure it implements the <NSCopying> protocol so that it can be a key in a dictionary.

You could also subclass NSString, if you want, and do -- effectively -- the same thing.

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to