Re: textfield with percent sign
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.