OStack程序员社区-中国程序员成长平台

标题: ios - AFNetworking 可达性ForLocalWiFi [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 18:41
标题: ios - AFNetworking 可达性ForLocalWiFi

AFNetworking 2 有什么方法可以等效

[Reachability reachabilityForLocalWiFi];



Best Answer-推荐答案


我查看了 Apple 可访问性代码,我认为这可以完成这项工作。

- (AFNetworkReachabilityManager*) reachabilityForLocalWifi
{
    struct sockaddr_in localWifiAddress;
    bzero(&localWifiAddress, sizeof(localWifiAddress));
    localWifiAddress.sin_len = sizeof(localWifiAddress);
    localWifiAddress.sin_family = AF_INET;

    // IN_LINKLOCALNETNUM is defined in <netinet/in.h> as 169.254.0.0.
    localWifiAddress.sin_addr.s_addr = htonl(IN_LINKLOCALNETNUM);

    return [AFNetworkReachabilityManager managerForAddress:&localWifiAddress];
}

关于ios - AFNetworking 可达性ForLocalWiFi,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21684413/






欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) Powered by Discuz! X3.4