- (BOOL)checkForWIFIConnection {
Reachability* wifiReach = [Reachability reachabilityForLocalWiFi];
NetworkStatus netStatus = [wifiReach currentReachabilityStatus];
if (netStatus!=ReachableViaWiFi)
{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"No WIFI available!", @"AlertView")
message:NSLocalizedString(@"You have no wifi connection available. Please connect to a WIFI network.", @"AlertView")
delegate:self
cancelButtonTitle:NSLocalizedString(@"Cancel", @"AlertView")
otherButtonTitles:NSLocalizedString(@"Open settings", @"AlertView"), nil];
[alertView show];
return NO:
}
return YES;
}
- (void)viewDidLoad {
[super viewDidLoad];
if([self checkForWIFIConnection]) {
[self parseXML]; // ...if this is here, but if i remove this line i get the UIALert saying no INTERNET
}
}
return the status (a BOOL) and check it before calling parseXML, as seen above.