I am building an application and trying to check and see if a device is still available on the network (by connecting to the devices IPAddress). I am using reachability to confirm that it is available.
When I network access for the iOS device (turn on airplane mode for example) everything works properly, but if I remove the device from the network, reachability does not seem to notice the change.
It seems like reachability is caching the results, and not seeing the update.
Don't use reachability then!
Use this bit of code instead which works a treat;
NSString *connected = [NSString stringWithContentsOfURL:[NSURL URLWithString:@"http://www.google.com"]];
wait(25000);
if (connected == NULL) {
NSLog(@"Not Connected");
//Code to show if not connected
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"Oops! You aren't connected to the Internet."
delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
[alert release];
} else {
NSLog(@"Connected Successfully!");
//Any other code for successful connection
}