1
我检查从苹果使用这个例子中,网络连接:如何检查网络更改iphone
- (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;
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;
}
}
}
我的意图是先检查一下,有一个连接,然后发送电子邮件。问题是,检查应用程序是否可以连接到主机需要很长时间,比如www.google.com需要花费将近一分钟的时间。有没有更快的方法来检查这个?
另一个问题是如何检查连接是否从wi-fi更改为3G。
在此先感谢!
我没有发件箱,因为我使用SKPSMTPMessage发送电子邮件。 – madcoderz