Pregunta

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

¿Fue útil?

Solución

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top