我在我的应用程序的代码:Reachability在iOS中的真正含义是什么?
-(void)reachAlert:(Reachability*)currentReach {
if(currentReach == hostReach) {
//Make sure we have internet connectivity
//UIAlertView *internetAlert = [[UIAlertView alloc] initWithTitle:@"Excellent" message:@"Host Reached" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Ok", nil];
//[internetAlert show];
[[SDSyncEngine sharedEngine] startSync];
}
/**
if(currentReach == internetReach) {
//Make sure we have internet connectivity
UIAlertView *internetAlert = [[UIAlertView alloc] initWithTitle:@"Good"
message:@"Internet"
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"Ok", nil];
[internetAlert show];
}
**/
if(currentReach == wifiReach) {
//Make sure we have internet connectivity
UIAlertView *internetAlert = [[UIAlertView alloc] initWithTitle:@"Bad News"
message:@"Only wifi"
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"Ok", nil];
[internetAlert show];
}
[TestFlight passCheckpoint:@"reachAlert"];
}
正如你可以看到我注释掉internetReach因为我算了一下,什么更重要的是,我们有hostReach。因此,默认情况下我们必须有互联网覆盖。我还评论了hostReach警报仅仅是因为我只想在没有互联网连接的情况下提醒用户。
但是在WiFi测试应用程序时,我得到的坏消息只有WiFi消息。为什么不提供hostReach警报?
好吧,我知道了......所以基本上只是在连接失败的情况下弹出alertview,对吧? – marciokoko
是的,错误1009意味着你无法连接。你当然可以得到其他的错误,所以你应该采取相应的行动。 –