Skip to content

Instantly share code, notes, and snippets.

@AlexHedley
Last active August 29, 2015 14:06
Show Gist options
  • Save AlexHedley/2f257ee45d78b83631cc to your computer and use it in GitHub Desktop.
Save AlexHedley/2f257ee45d78b83631cc to your computer and use it in GitHub Desktop.
Reachability
//http://iosameer.blogspot.co.uk/2013/01/checking-internet-connection-in-ios-apps.html
#import "Reachability.h"
//// Just use it ,Where you need it (checking internet connection)
Reachability *reachTest = [Reachability reachabilityWithHostName:@"www.apple.com"];
NetworkStatus internetStatus = [reachTest currentReachabilityStatus];
if ((internetStatus != ReachableViaWiFi) && (internetStatus != ReachableViaWWAN)) {
/// Create an alert if connection doesn't work,no internet connection
UIAlertView *myAlert = [[UIAlertView alloc] initWithTitle:@"No Internet Connection"
message:@"You require an internet connection via WiFi or cellular network for location finding to work."
delegate:self
cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
[myAlert show];
[myAlert release];
}
else {
// There is a internet connection
/// Do,Whatever you want
}
//https://developer.apple.com/library/ios/samplecode/Reachability/Introduction/Intro.html
//https://github.com/tonymillion/Reachability
//http://code.tutsplus.com/tutorials/ios-sdk-detecting-network-changes-with-reachability--mobile-18299
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment