tony million可达性说连接时无法连接

我已经search,但没有发现像我的问题。 我确定这是我看过的东西。

我正在使用tony百万的可达性块的方法。 当我有互联网,然后没有互联网,这是工作良好。 警报出现,工作得很好。

但是,当我没有互联网,然后我得到互联网相同的警报popup

我的代码是

-(void)reachabilityBlock { // allocate a reachability object Reachability * reach = [Reachability reachabilityWithHostname:@"www.google.com"]; // tell the reachability that we DONT want to be reachable on 3G/EDGE/CDMA reach.reachableOnWWAN = YES; reach.reachableBlock = ^(Reachability * reachability) { dispatch_async(dispatch_get_main_queue(), ^{ //NSLog(@"REACHABLE! block"); [self newsTableViewRefresher]; }); }; reach.unreachableBlock = ^(Reachability * reachability) { dispatch_async(dispatch_get_main_queue(), ^{ //NSLog(@"UNREACHABLE! block"); UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"No Network found!" message: @"You have no wifi or cellular connection available. Please connect to a WIFI or cellular network." delegate: self cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show]; }); }; [reach startNotifier]; [self.refreshControl endRefreshing]; } 

我的问题是为什么当我上网不能达到警报popup?

感谢您的时间

这就是我为了我而做的,为我完成了工作。 我尝试使用块,但似乎解决我的问题更麻烦。 希望这可以帮助。

 Reachability *reach = [Reachability reachabilityWithHostname:@"www.jportdev.com"]; if ([reach isReachable]){ // Reachable //NSLog(@"is reachable......."); }else{ // not Reachable UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Network is unavaliable!" message:@"Some content in this application might not be avaliable without network connectivity." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show]; alert = nil; }