Ok, I understand that using strings that have special characters is an encoding issue.
However I am not sure how to adjust my code to allow these characters. Below is the code that works great for text that contains no special characters, but can you show me how and where to change the code to allow for the special characters to be used. Right now those characters crash the app.
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
if (buttonIndex == 1) {
//iTunes Audio Search
NSString *stringURL = [NSString stringWithFormat:@"http://phobos.apple.com/WebObjects/MZSearch.woa/wa/search?WOURLEncoding=ISO8859_1&lang=1&output=lm&term=\"%@\"",currentSong.title];
stringURL = [stringURL stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
NSURL *url = [NSURL URLWithString:stringURL];
[[UIApplication sharedApplication] openURL:url];
}
}
And this:
-(IBAction)launchLyricsSearch:(id)sender{
WebViewController * webView = [[WebViewController alloc] initWithNibName:@"WebViewController" bundle:[NSBundle mainBundle]];
webView.webURL = [NSString stringWithFormat:@"http://www.google.com/m/search?hl=es&q=\"%@\"+letras",currentSong.title];
webView.webTitle = @"Letras";
[self.navigationController pushViewController:webView animated:YES];
}
Please show me how and where to do this for these two bits of code.
Ok Dave’s answer works great for Part 1:
Working Code:
However, Part 2 isn’t there yet (I know its me… but could you help?)
What would be the correct code to get webView.webURL to allow spanish characters like “ñ”?