reachabilityWithHostName 超时
我正在实现 Reachability 类来检查连接状态,如下所示:
Reachabilitty *reachability = [Reachability reachabilityWithHostName:@"apple.com"];
Network status = [reachability currentReachabilityStatus];
if(status == NotReachable){
...
}else if(status == ReachableViaWifi){
...
}else if(status == ReachableViaWWNA){
...
}
当我调用 apple.com 来检查连接时,可以设置超时吗?
I'm implementing the Reachability class to check connection status as follows:
Reachabilitty *reachability = [Reachability reachabilityWithHostName:@"apple.com"];
Network status = [reachability currentReachabilityStatus];
if(status == NotReachable){
...
}else if(status == ReachableViaWifi){
...
}else if(status == ReachableViaWWNA){
...
}
It's possible to set a timeOut when I'm calling to apple.com to check connection?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为此,您必须使用计时器或线程。
You have to use timer or thread for this.
这是苹果公司的,非常好。
------------ M 文件
使用 startNotifier 和 stopNotifier 监视 WiFi 状态
实现
将 UILabel 和 UIButton 添加到视图
将以下内容添加到您的 .h 文件
这是您的 .M 文件
This is from Apple and it's really good.
------------ M File
Use startNotifierand stopNotifier to monitor WiFi status
Implementation
Add a UILabel and UIButton to a view
Add the following to your.h file
Here is your .M file