Created
January 13, 2014 16:40
-
-
Save jchudzynski/8403445 to your computer and use it in GitHub Desktop.
Checks if internet connection is offline.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(BOOL)checkIfOnline{ | |
NSURL *scriptUrl = [NSURL URLWithString:@"http://google.com/m"]; | |
NSData *data = [NSData dataWithContentsOfURL:scriptUrl]; | |
if (data){ | |
NSLog(@"Device is connected to the internet"); | |
return YES;} | |
else | |
NSLog(@"Device is not connected to the internet"); | |
return NO; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment