如何获取所有WiFi连接

时间:2016-08-02 10:46:21

标签: ios objective-c iphone wifi

请解决我的问题,如果有人知道要找到附近的所有WiFi连接。实际上我想连接iPhone到Android和iPhone到iPhone反之亦然发送文本。

1 个答案:

答案 0 :(得分:1)

以下是您可以参考的代码。

- (NSDictionary *)fetchSSIDInfo
{

NSArray *interfaceNames = CFBridgingRelease(CNCopySupportedInterfaces());
NSLog(@"%s: Supported interfaces: %@", __func__, interfaceNames);

NSDictionary *SSIDInfo;
for (NSString *interfaceName in interfaceNames) {
    SSIDInfo = CFBridgingRelease(
        CNCopyCurrentNetworkInfo((__bridge CFStringRef)interfaceName));
    NSLog(@"%s: %@ => %@", __func__, interfaceName, SSIDInfo);

    BOOL isNotEmpty = (SSIDInfo.count > 0);
    if (isNotEmpty) {
        break;
    }
}
return SSIDInfo;

}