• 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
textfield with percent sign
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

textfield with percent sign


  • Subject: textfield with percent sign
  • From: emh <email@hidden>
  • Date: Sun, 1 Feb 2004 11:20:05 -0800

hi all,

new to the list (and cocoa/objc development) but i couldn't find any
answers in either online docs or list archives.

i have a textfield where i want the user to input a search phrase. i
then plan on appending that phrase to the URL of a search engine, i.e.

NSString* searchterm = [textfield stringValue];
NSString* urlStr = [NSString
stringWithFormat:@"http://www.blah.com/search?select=&for=%@";,
searchTerm];

the problem is, if the user types in something like "%@" for the
searchterm, the program blows up. it looks like it is treating the % as
a formatting character.

how do i stop it from doing that?

i tried using the stringByAddingPercentEscapesUsingEncoding method on
NSString but that only provided bizarre results -- maybe i used the
wrong encoding (i tried ASCII and UTF8).

any help would be appreciated!

also, note that this doesn't have much to do with the URL stuff -- a
simple NSLog(searchTerm) will blow up the app if searchTerm is "%@".

evan.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: textfield with percent sign
      • From: Peter Maurer <email@hidden>
    • Re: textfield with percent sign
      • From: Pete Yandell <email@hidden>
    • Re: textfield with percent sign
      • From: Herr Witten <email@hidden>
    • Re: textfield with percent sign
      • From: Reimar Metzen <email@hidden>
  • Prev by Date: How to set up manual bindings
  • Next by Date: Re: Dragging Image
  • Previous by thread: Re: How to set up manual bindings
  • Next by thread: Re: textfield with percent sign
  • Index(es):
    • Date
    • Thread