gpt4 book ai didi

ios - 可达性问题 iOS9

转载 作者:行者123 更新时间:2023-11-29 12:13:12 26 4
gpt4 key购买 nike

我在我的项目中使用 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com