9

In one of my iPhone app, I need to find out whether there is internet connection with the device or not. Anyone pls help?

Krishna Raj Salim
  • 7,331
  • 5
  • 34
  • 66

1 Answers1

8

Use Reachability class.

  if([self checkInternetConnected] ) 
  {
    NSLog(@"Internet connected\n");
  } 


- (BOOL)checkInternetConnected 
{
    Reachability *reachability = [Reachability reachabilityForInternetConnection];  
    NetworkStatus networkStatus = [reachability currentReachabilityStatus]; 
    return !(networkStatus == NotReachable);
}

You can get rechability class here : Download sample and add Reachability.h and Reachability.m into your project.

Guru
  • 21,652
  • 10
  • 63
  • 102
  • And then you must add: SystemConfiguration.framework if you haven't added it yet! Good luck – Tai Le Apr 20 '15 at 11:41