1、到苹果管网下载Reachability的Demo,https://developer.apple.com/library/ios/#samplecode/Reachability/Introduction/Intro.html
然后把:Reachability.h 和 Reachability.m 添加到工程中
bool CCNetworkConfig::isNetworkAvailable()
{
Reachability *r = [ReachabilityreachabilityWithHostName:@"www.apple.com"];
switch ([rcurrentReachabilityStatus]) {
caseReachableViaWWAN: // 使用3G网络
printf("current network 3g/gprs\n");
return true;
caseReachableViaWiFi: // 使用WiFi网络
printf("current network wifi\n");
return true;
caseNotReachable: // 没有网络连接
default:
break;
}
printf("current network none\n");
return false;
}
本文介绍如何使用Apple提供的Reachability示例代码来检测iOS设备的网络状态,包括3G、GPRS和WiFi连接,并提供了具体的实现方法。
2671

被折叠的 条评论
为什么被折叠?



