Re: NSDictionary valueForKey: and @ character at start of NSString
Re: NSDictionary valueForKey: and @ character at start of NSString
- Subject: Re: NSDictionary valueForKey: and @ character at start of NSString
- From: "Joe Goh" <email@hidden>
- Date: Tue, 15 May 2007 21:46:50 +0800
On 5/15/07, Buddy Kurz <email@hidden> wrote:
How about prepending some other character when the key is stored and
removing it when reading the key to get the string
NSString * myKey = [NSString stringWithFormat:@"-%@",userString];
NSString * userString = [myKey stringFromIndex:1];
The problem with this approach is that its rather brittle, as I need
to remember to do this everytime I call NSDictionary valueForKey:. If
I prepend the string with some character once I receive the input, and
only strip it out when I need to output it or manipulate it, its also
really brittle and unmaintainable as this will lead to sprinkling lots
of stringFromIndex: method calls all over the place. I think this is
a rather unmaintainable approach in general and i'd much rather avoid
it.
On the main topic again though; will my category implementation as
described in my original email cause any problems with internal Cocoa
APIs or otherwise?
Joe Goh
FunkeeMonk Technology
http://www.funkeemonk.com/
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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