可达性块应用
在我的应用程序中的 appDelegate .mi 中插入了像苹果所说的可达性代码:
-(BOOL)checkInternet
{
Reachability *r = [Reachability reachabilityWithHostName:@"google.com"];
NetworkStatus internetStatus = [r currentReachabilityStatus];
BOOL internet;
if ((internetStatus != ReachableViaWiFi) && (internetStatus != ReachableViaWWAN)) {
internet = NO;
} else {
internet = YES;
}
return internet;
}
并在我的 viewcontroller.m 中的方法中 - (void)applicationDidBecomeActive:(UIApplication *)application {
gotInternet = [self checkInternet];
if ( gotInternet == 0)
{
//No connection
} else {
//Connection ok
}
但是当网络 3g 出现问题时我的应用程序之后大约 20 秒,由于延迟太大,它崩溃了。如何异步实现控制连接,而不带看门狗?
谢谢
in my app in the appDelegate .m i have insert the reachability code like apple say:
-(BOOL)checkInternet
{
Reachability *r = [Reachability reachabilityWithHostName:@"google.com"];
NetworkStatus internetStatus = [r currentReachabilityStatus];
BOOL internet;
if ((internetStatus != ReachableViaWiFi) && (internetStatus != ReachableViaWWAN)) {
internet = NO;
} else {
internet = YES;
}
return internet;
}
and in my viewcontroller.m in the method - (void)applicationDidBecomeActive:(UIApplication *)application {
gotInternet = [self checkInternet];
if ( gotInternet == 0)
{
//No connection
} else {
//Connection ok
}
but when there are problems on the network 3g my application after about 20 seconds it crashes because of too much latency. How do I implement the control connection asynchronously, never to take the watchdog?
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看看
NSOperation
和 并发编程指南。Have a look at
NSOperation
and the concurrency programming guide.