[英]How to check whether there is internet connection with the device: cocos-2d
在我的一个iPhone应用程序中,我需要确定是否与设备有互联网连接。 有人帮忙吗?
使用Reachability类。
if([self checkInternetConnected] )
{
NSLog(@"Internet connected\n");
}
- (BOOL)checkInternetConnected
{
Reachability *reachability = [Reachability reachabilityForInternetConnection];
NetworkStatus networkStatus = [reachability currentReachabilityStatus];
return !(networkStatus == NotReachable);
}
您可以在此处获取rechability类:下载示例并将Reachability.h和Reachability.m添加到您的项目中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.