Re: textfield with percent sign
Re: textfield with percent sign
- Subject: Re: textfield with percent sign
- From: Pete Yandell <email@hidden>
- Date: Mon, 2 Feb 2004 10:24:54 +1100
My bet is that the code you provided is doing the right thing and that
something that you're doing afterwards is confusing you.
For example, let's say your newly generated urlStr looks like:
http://www.blah.com/search?select=&for=silly %@ example
and then you use NSLog (urlStr) to check this value get:
http://www.blah.com/search?select=&for=silly example
or possibly some other garbage.
NSLog (@"%@", urlStr) on the other hand will print the right value.
So what do you mean when you say your program "blows up"? What are you
doing with urlStr once you've generated it?
Pete Yandell
http://pete.yandell.com/
On 02/02/2004, at 6:20 AM, 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?
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.
_______________________________________________
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.