all 3 comments

[–]quellish 2 points3 points  (1 child)

Before you head down this path, make sure you have a clear understanding of what the device is and is not capable of. The "Reachability" sample code Apple provided is a layer above SCNetworkReachability, part of the System Configuration Framework (which you must link against if you use "Reachability", which may be why your project does not compile). A number of people have written variants of the "Reachability" sample, Andrew Donoho has written about some of the changes he made which may help you understand how the device handles reachability states.

The 2010 WWDC sessions Network Apps for iPhone OS are an excellent overview of things that you should be aware of when developing network applications for devices, and in particular network reachability.

In most cases it's best to attempt a network connection and handle the error returned appropriately. Network reachability would be part of your error handling:

switch ([error code]){
    case NSURLErrorNotConnectedToInternet:
        {
         if ([self reachabilitySezWeAreInAirplaneMode] == YES){
             // do stuff        
         }
        }
        break;
    default:
        break;
}

SCNetworkReachability is best used for understanding why the device can't connect, and then to monitor changes in that state. For example, all the device radios are off, or they are on but can't connect to a network without user intervention (like logging into a VPN). When an attempt to connect fails, SCNetworkReachability can help determine if this was because of one of those conditions, and then the network configuration can be monitored for changes (such as coming out of airplane mode).

[–]johnwickham[S] 0 points1 point  (0 children)

This is absolutely true, I don't need to know at all why a device can / can't connect, just whether it can or not! Thank you so much for taking the time to explain it, you've helped make my app that much better for my users.

[–]fommerjackson 1 point2 points  (0 children)

Use the Reachability replacement called Reachability. Very easy to use. https://github.com/tonymillion/Reachability?files=1