• 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
Re: NSDictionary valueForKey: and @ character at start of NSString
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: NSDictionary valueForKey: and @ character at start of NSString
      • From: "Clark Cox" <email@hidden>
References: 
 >NSDictionary valueForKey: and @ character at start of NSString (From: "Joe Goh" <email@hidden>)
 >Re: NSDictionary valueForKey: and @ character at start of NSString (From: Sam Stigler <email@hidden>)
 >Re: NSDictionary valueForKey: and @ character at start of NSString (From: "Joe Goh" <email@hidden>)
 >Re: NSDictionary valueForKey: and @ character at start of NSString (From: Buddy Kurz <email@hidden>)

  • Prev by Date: Re: Counting NSMutableSet
  • Next by Date: Re: Out-of-bounds error when removing entry from NSForm
  • Previous by thread: Re: NSDictionary valueForKey: and @ character at start of NSString
  • Next by thread: Re: NSDictionary valueForKey: and @ character at start of NSString
  • Index(es):
    • Date
    • Thread