Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find the 404 error cause, when I am using a webview based application and the server fails in iphone sdk

I am implementing a webview based application, in that I need to find out a way when the 404 error occurred.

Anyone's help will be much appreciated.

Thanks to all, Monish.

like image 770
Monish Kumar Avatar asked Dec 21 '10 07:12

Monish Kumar


2 Answers

In the webViewDidFinishLoad method, you can also check it this way:

NSCachedURLResponse *resp = [[NSURLCache sharedURLCache] cachedResponseForRequest:webView.request];
NSLog(@"status code: %ld", (long)[(NSHTTPURLResponse*)resp.response statusCode]);
like image 194
Sandy D. Avatar answered Sep 30 '22 18:09

Sandy D.


webViewDidFinishLoad() method writes following code and checks status code...

- (void)webViewDidFinishLoad:(UIWebView *)webview {

    NSCachedURLResponse *urlResponse = [[NSURLCache sharedURLCache] cachedResponseForRequest:webview.request];
    NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse*) urlResponse.response;
    NSInteger statusCode = httpResponse.statusCode;
}
like image 32
Subhash Khimani Avatar answered Sep 30 '22 16:09

Subhash Khimani