You can check whether there is internet connection with the device/not with the help of following code:
// in .h File //
Import Reachability class.
// in .m File //
if([self connected] )
{
NSLog(@"Internet connected\n");
}
- (BOOL)connected
{
Reachability *reachability = [Reachability reachabilityForInternetConnection];
NetworkStatus networkStatus = [reachability currentReachabilityStatus];
return !(networkStatus == NotReachable);
}
// in .h File //
Import Reachability class.
// in .m File //
if([self connected] )
{
NSLog(@"Internet connected\n");
}
- (BOOL)connected
{
Reachability *reachability = [Reachability reachabilityForInternetConnection];
NetworkStatus networkStatus = [reachability currentReachabilityStatus];
return !(networkStatus == NotReachable);
}
No comments:
Post a Comment