I have a code to detect if I have internet connection or not, and sometimes it doesn’t work well. Here’s the code:
-(void) webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
UIAlertView *alert= [[UIAlertView alloc] initWithTitle:@"Error" message:@"Couldn't connect to the Internet. Please check your connection." delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alert show];
[alert release];
}
The problem is that sometimes a web doesn’t load for other things and not because it has a bad connection. I hope that there’s a better way to check the WiFi. Any idea?
I suggest you follow the link and read the best marked answer given in there. It worked perfectly with me.
How to check for an active Internet connection on iOS or OSX?