Този случай (NSLog(@"A gateway to the host server is down."); винаги се изпълнява по някаква причина.
Използвам класа на Apple Reachability зад сцената. Опитах се да вмъкна други хостове, но без успех, моля, помогнете.
Благодаря предварително.
Ето кода
@implementation ConnectionManager
@synthesize internetActive, hostActive;
-(id)init {
self = [super init];
if(self) {
}
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(checkNetworkStatus:) name:@"NetworkReachabilityChangedNotification" object:nil];
internetReachable = [Reachability reachabilityForInternetConnection];
[internetReachable startNotifier];
hostReachable = [Reachability reachabilityWithHostName:@"www.google.com"];
[hostReachable startNotifier];
return self;
}
- (void) checkNetworkStatus:(NSNotification *)notice
{
NetworkStatus internetStatus = [internetReachable currentReachabilityStatus];
switch (internetStatus)
{
case NotReachable:
{
NSLog(@"The internet is down.");
self.internetActive = NO;
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;
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;
}
}
}
[Reachability reachabilityWithHostName:@"www.google.com"];
на[Reachability reachabilityWithHostName:@"http://www.google.com"];
и проверете. - person iDev   schedule 15.02.2013