ios检测是否有网络连接
2012-09-19 17:34
323 查看
去这里http://developer.apple.com/iphone/library/samplecode/Reachability/Introduction/Intro.html#//apple_ref/doc/uid/DTS40007324-Intro-DontLinkElementID_2 下载Reachability.m和Reachability.h,然后添加到你的项目里面,在需要测试网络连接class里面写这样的一个方法
- (BOOL)testConnection {
BOOL result = YES;
Reachability *reach=[Reachability sharedReachability];
[reach setHostName:@“你自己输入一个网址来做ping”];
NetworkStatus status;
status=[reach remoteHostStatus];
if (status == NotReachable) {
result = NO;
} else if (status == ReachableViaCarrierDataNetwork) {
result = YES;
} else if (status == ReachableViaWiFiNetwork) {
result = YES;
}else {
result = NO;
}
return result;
}
- (BOOL)testConnection {
BOOL result = YES;
Reachability *reach=[Reachability sharedReachability];
[reach setHostName:@“你自己输入一个网址来做ping”];
NetworkStatus status;
status=[reach remoteHostStatus];
if (status == NotReachable) {
result = NO;
} else if (status == ReachableViaCarrierDataNetwork) {
result = YES;
} else if (status == ReachableViaWiFiNetwork) {
result = YES;
}else {
result = NO;
}
return result;
}
相关文章推荐
- iOS下的实际网络连接状态检测
- Android 检测网络连接是否可用
- IOS检测网络连接状态(转)
- IOS使用Reachability实时检测网络连接状况
- IOS检测网络连接状态(转)
- 检测网络是否连接正常
- 检测网络是否为WIFI连接
- [ios开发]判断网络连接是否正常
- iOS下的实际网络连接状态检测(转)
- iOS 检测网络是否可以使用
- IOS使用Reachability实时检测网络连接状况
- IOS使用Reachability实时检测网络连接状况
- iOS检查网络是否连接
- 广播接收检测是否连接网络
- android的网络是否连接状态检测及具体连接的网络类型
- ios检测是否有网络
- 李洪强iOS下的实际网络连接状态检测
- iOS下的实际网络连接状态检测
- android 检测网络是否连接
- C#检测当前用户网络是否连接