Apple provides a class called Reachability. I almost used it, but then I found that many people report problems in SO. For example, it will report false positives or cause the same error notification several times, so that the user repeatedly removes the notification that there is no Internet.
Why can't I just try to extract the data in the background and see what I get?
NSData *download = [NSData dataWithContentsOfURL:[NSURL URLWithString:urlStr]];
I checked: when there is no Internet, download
will be just zero. Then I can call UIAlertView and complain.
Also, some users say that it’s stupid to just check the “Internet connection” because Reachability only reports the connection to the Gateway. Gateway does not have internet. My WiFi router does this all the time. The iPad has Wi-Fi reception, but not internet.
Others say it's best to check for a specific URL and see if there is a server.
So why bother with the Reachability class? Why not try the actual download, and if nothing happens, assume something is wrong?
source share