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