ios WiFi

作者: BlueSky520 | 来源:发表于2016-12-09 17:48 被阅读0次

    真机上测试

    - (id)fetchSSIDInfo {

    NSArray *ifs = (id)CFBridgingRelease(CNCopySupportedInterfaces());

    NSLog(@"%s: Supported interfaces: %@", __func__, ifs);

    id info = nil;

    for (NSString *ifnam in ifs) {

    info = (id)CFBridgingRelease(CNCopyCurrentNetworkInfo((CFStringRef)ifnam));

    if (info && [info count]) {

    break;

    }

    }

    return info;

    }

    - (NSString * )currentWifiSSID {

    //    Does not work on the simulator.

    NSString *ssid = nil;

    NSArray *ifs = (  id)CFBridgingRelease(CNCopySupportedInterfaces());

    NSLog(@"ifs:%@",ifs);

    for (NSString *ifnam in ifs) {

    NSDictionary *info = (id)CFBridgingRelease(CNCopyCurrentNetworkInfo((CFStringRef)ifnam));

    NSLog(@"dici:%@",[info  allKeys]);

    if (info[@"SSIDD"]) {

    ssid = info[@"SSID"];

    }

    }

    return ssid;

    }

    相关文章

      网友评论

        本文标题:ios WiFi

        本文链接:https://www.haomeiwen.com/subject/bjfymttx.html