• 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: Herr Witten <email@hidden>
  • Date: Sun, 1 Feb 2004 14:43:42 -0500

maybe convert your search string to an NSMutableString and then use:

replaceOccurrencesOfString:withString:options:range:

for example:

NSMutableString search = [NSMutableString stringWithString:
searchterm];
[search replaceOccurrencesOfString: @"%"
withString: @"\%"
options: NSLiteralSearch
range: NSMakeRange(0, [search length])];

On 1 Feb 2004, at 2:20 PM, emh wrote:

> 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?
_______________________________________________
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: Re: textfield with percent sign
  • Next by Date: Re: Multiple Undo devours RAM
  • Previous by thread: Re: textfield with percent sign
  • Next by thread: Re: textfield with percent sign
  • Index(es):
    • Date
    • Thread