アプリでインターネット接続を確認したい。その間、次のコードを使用します。internetStatusとホストステータスの違いは何ですか。iPadがインターネットに接続されているかどうかを確認するためにどちらを使用する必要がありますか。
-(void) checkNetworkStatus:(NSNotification *)notice
{
// called after network status changes
NetworkStatus internetStatus = [internetReachable currentReachabilityStatus];
switch (internetStatus)
{
case NotReachable:
{
//NSLog(@"The internet is down.");
//self.internetActive = NO;
//NSLog(@"A gateway to the host server is down.");
//self.hostActive = NO;
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Connection Failed"
message:@"No internet connection"
delegate:nil
cancelButtonTitle:@"Exit"
otherButtonTitles:nil];
[alert setDelegate:self];
[alert show];
[alert release];
break;
}
case ReachableViaWiFi:
{
//NSLog(@"The internet is working via WIFI.");
//self.internetActive = YES;
break;
}
case ReachableViaWWAN:
{
//NSLog(@"The internet is working via WWAN.");
//self.internetActive = YES;
break;
}
}
NetworkStatus hostStatus = [hostReachable currentReachabilityStatus];
switch (hostStatus)
{
case NotReachable:
{
//NSLog(@"A gateway to the host server is down.");
//self.hostActive = NO;
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Connection Failed"
message:@"No internet connection"
delegate:nil
cancelButtonTitle:@"Exit"
otherButtonTitles:nil];
[alert setDelegate:self];
[alert show];
[alert release];
break;
}
case ReachableViaWiFi:
{
//NSLog(@"A gateway to the host server is working via WIFI.");
//self.hostActive = YES;
break;
}
case ReachableViaWWAN:
{
//NSLog(@"A gateway to the host server is working via WWAN.");
//self.hostActive = YES;
break;
}
}
}