我在我的项目中使用 Apple Reachability 类。我用它来检查网络和 VPN 连接。当 VPN 未连接时,当我调用 reachabilityWithHost 方法时,它让我无法访问。但在 iOS9 中,它不起作用。即使未连接 VPN,它也显示主机可访问。如果有人遇到同样的问题,请发布解决方案
最佳答案
终于找到了使用iOS9(也兼容iOS7-8)检查连接的方法
NSURL* fullURL = [NSURL URLWithString:@"http://reachable-in-VPN-only.com"];
BOOL isDataSourceAvailable = NO;
if ([fullURL host])
{
NSString* hostname = [fullURL host];
CFHostRef hostRef = CFHostCreateWithName(kCFAllocatorDefault, (CFStringRef)hostname);
isDataSourceAvailable = CFHostStartInfoResolution(hostRef, kCFHostAddresses, nil);
}
关于ios - 可达性问题 iOS9,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32734497/