views:

55

answers:

2

How would one catch loadRequest returning a 404 page,

i am calling the load request like so:

[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:qype_url]]];

can't seem to figure out how to catch what it returns so i can deal with this situation and load an error page. If the url is incorrect a blank page is returned for example: http://i.qype.co.uk/place/2535934 but how do i catch this in my code? thanks!

+2  A: 

You can listen for

- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error

part of UIWebViewDelegate

OTisler
A: 

I found a solution for catching pages such as 404's which do not fire the didFailLoadWithError method.

- (SCNetworkReachabilityRef)reachabilityRefForHostName:(NSString *)hostName

http://developer.apple.com/iphone/library/samplecode/Reachability/Introduction/Intro.html

Alex