I have an animal list and special button. When I press the button, I would like to go to Wikipedia and read about this animal more. So I wrote this code:
-(IBAction)goWiki:(id)sender
{
NSString *wikiUrl = "http://ru.wikipedia.org/wiki/";
NSString *url = [NSString stringWithFormat:@"%@%@",wikiUrl,animalTitle];
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:url]];
NSLog(@"%@",url);
}
NSLog
shows that url was written correctly, however, nothing happened. I am 99,9% sure its because of animalTitle
. My native language is russian and animalTitle
is also an animal name in russian.
So if link is like http://ru.wikipedia.org/wiki/Frog its fine and it works but if its like
http://ru.wikipedia.org/wiki/Лягушка nothing happens.
Any ideas, how can I move to a russian article?
Thanks!
use
stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding
as follows -Try passing the string
animalTitle
through CFURLCreateStringByAddingPercentEscapes first.