Skip to content

Instantly share code, notes, and snippets.

@jchudzynski
Created January 13, 2014 16:40
Show Gist options
  • Save jchudzynski/8403445 to your computer and use it in GitHub Desktop.
Save jchudzynski/8403445 to your computer and use it in GitHub Desktop.
Checks if internet connection is offline.
-(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