Nam Young-jun
Nam Young-jun

Reputation: 121

WebKitErrorDomain error 101

The following code produces and error of:

WebKitErrorDomain error 101 

code:

-(Void) searchBarSearchButtonClicked: (UISearchBar *) activeSearchBar { 
    NSString * query = [searchBar.text stringByReplacingOccurrencesOfString: @ "" withString: @ "+"]; 
    NSURL * url = [NSURL URLWithString: [NSString stringWithFormat: @ "http://http://www.google.com/search?q =%, query]]; 
    NSURLRequest * requestObj = [NSURLRequest requestWithURL: url]; 
    [Home loadRequest: requestObj]; 
} 

-(Void) loadView { 
     [Super loadView]; 
     CGRect bounds = [[UIScreen mainScreen] applicationFrame];   
     searchBar = [[UISearchBar alloc] initWithFrame: CGRectMake (0.0, 0.0, bounds.size.width, 48.0)]; 
     searchBar.delegate = self; 
     [Self.view addSubview: searchBar];
}

I don't speak english and rely on a translator. Because of the language issue could this be a keyboard problem, or an encoding problem?

Upvotes: 12

Views: 20310

Answers (3)

Nupur Sharma
Nupur Sharma

Reputation: 1214

Do not add whitespace in your string url.

Upvotes: 5

Rakul
Rakul

Reputation: 109

Make Sure that your url doesn't contain white space and new line characters.

To do this you can use the following code:

NSString *newString = [url stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];

Upvotes: 2

TechZen
TechZen

Reputation: 64428

According to the WebKitError header, error 101 means, "WebKitErrorCannotShowURL" which is not very helpful.

This line is incorrect:

NSURL * url = [NSURL URLWithString: [NSString stringWithFormat: @ "http://http://www.google.com/search?q =%, query]]; 

... it should look like:

NSURL * url = [NSURL URLWithString: [NSString stringWithFormat: @ "http://www.google.com/search?q =%@", query]]; 

I'm not sure if that it causing the error by producing a bad URL or if it is a typo.

Upvotes: 5

Related Questions