So I have made a text field, where I can search a web or in Google. The problem is that I can’t search more than one word on google: I can search Stackoverflow, but I can’t search Stackoverflow questions, for example. Here’s the code:
{
if ([textField.text hasPrefix:@"http"]){
url=[NSURL URLWithString:[textField text]];
request = [NSURLRequest requestWithURL:url];
[webView loadRequest:request];
}else{
stringOne = @"http://www.google.com/search?q=";
NSString *stringTwo = TextField.text;
NSString *googleSearchString =[stringOne stringByAppendingString:stringTwo];
NSURL *google = [NSURL URLWithString:googleSearchString ];
request = [NSURLRequest requestWithURL:google ];
[webView loadRequest:request];
}
}
Thank you for helping!
Your string may not be encoded correctly. Maybe try: