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

Re: textfield with percent sign


  • Subject: Re: textfield with percent sign
  • From: Peter Maurer <email@hidden>
  • Date: Mon, 2 Feb 2004 08:09:19 +0100

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.

The easiest way to avoid this problem (which I have experienced, too) is to use [[theURLPrefix stringByAppendingString: theQuery] stringByAppendingString: theURLSuffix] instead of [NSString
stringWithFormat: theURL, theQuery] -- at least, that's what I do in <product placement>Another Launcher</product placement>.

By the way, it is definitely a good idea to encode the query. The most common string encoding in western search engines is ISO Latin 1.

Peter Maurer.
_______________________________________________
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.

References: 
 >textfield with percent sign (From: emh <email@hidden>)

  • Prev by Date: MEETING: Chicago - Tuesday Feb 3rd 6:00 PM
  • Next by Date: Re: Row moving [source]
  • Previous by thread: Re: textfield with percent sign
  • Next by thread: Re: Multiple Undo devours RAM
  • Index(es):
    • Date
    • Thread