I have searched but have not found an issue like mine. I'm sure it's something I have over looked .
I am using tony million's reachability block method. it is working good when i have internet then no internet. the alert comes up and works just fine.
but, when i have no internet and then i get internet the same alert pops up
my code is
-(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];
}
my question is why when i get internet does the unreachable alert pop up?
thank you for your time
[Reachability reachabilityForInternetConnection];
instead of[Reachability reachabilityWithHostname:@"www.google.com"];
– Arrowhead