zoukankan      html  css  js  c++  java
  • ios 获取当前wifi名称

    ios5之前可以通过读取配置文件获取,ios5以后苹果修改wifi列表文件位置,只有root权限才可以读取.

    ios4:/System/Library/SystemConfiguration/WiFiManager.bundle/WiFiManager

    ios5:/System/Library/SystemConfiguration/IPConfiguration.bundle/IPConfiguration

    官方的API没有提供获取扫描所有wifi列表,相近功能的只有CaptiveNetwork,获取当前wifi的名称。

    引用头文件<SystemConfiguration/CaptiveNetwork.h>

    /*!
     @function CNCopySupportedInterfaces
     @discussion copies a list of all interfaces CaptiveNetworkSupport is monitoring.
     @result An array of CFStringRef- BSD interface names.
    	 Returns NULL if an error was encountered.
    	 You MUST release the returned value.
     */
    CFArrayRef
    CNCopySupportedInterfaces	(void)				__OSX_AVAILABLE_STARTING(__MAC_10_8,__IPHONE_4_1);
    

    通过CNCopySupportedInterfaces获取wifi列表,实际测试中返回数组中只有一个值,即当前连接的wifi。

    - (NSString *)currentWifiSSID 
    {
        NSString *ssid = nil;
        NSArray *ifs = (__bridge   id)CNCopySupportedInterfaces();
        for (NSString *ifname in ifs) {
            NSDictionary *info = (__bridge id)CNCopyCurrentNetworkInfo((__bridge CFStringRef)ifname);
            if (info[@"SSIDD"])
             {
                ssid = info[@"SSID"];
            }
        }
        return ssid;
    }
        
    
  • 相关阅读:
    在Ubuntu下安装TensorFlow-gpu版本
    ubuntu安装和卸载软件命令
    Window7通过Anaconda安装Tensorflow
    Kaggle Titanic Data Science Solutions
    CNN、RNN和DNN的区别
    卷积神经网络介绍
    大数据随想
    golang omitempty 总结
    LeetCode 856 递归思路详解
    安装Nginx的各种报错的解决
  • 原文地址:https://www.cnblogs.com/geweb/p/CaptiveNetwork.html
Copyright © 2011-2022 走看看