美文网首页
iOS-获取设备wifi 和Mac地址-获取info.plist

iOS-获取设备wifi 和Mac地址-获取info.plist

作者: 离子来了 | 来源:发表于2016-10-10 15:08 被阅读668次
    
    import SystemConfiguration.CaptiveNetwork
    
    class BaseDeviceinfoUtil: NSObject {
        /**
         获取wifi名字和mac地址
         */
       class func getWifiInfo()->(ssid:String,mac:String){
            
            if let cfas: NSArray = CNCopySupportedInterfaces() {
                for cfa in cfas {
                    if let dict = CFBridgingRetain(CNCopyCurrentNetworkInfo(cfa as! CFString)) {
                        return (T(dict["SSID"]), T(dict["BSSID"]))
                    }
                }
            }
            return ("未知", "未知")
        }
        
    }
    

    获取info.plist的信息

    let deviceInfo = NSBundle.mainBundle().infoDictionary
    let appVersion      = T(deviceInfo?["CFBundleShortVersionString"])
    let appBuildVersion = T(deviceInfo?["CFBundleVersion"])
    let appName         = T(deviceInfo?["CFBundleDisplayName"])
    let identifier      = T(deviceInfo?["CFBundleIdentifier"])
    通过上面的key,能很好的得出规律这个key都是以CFBundle开头,接上后面的Identifier,
    有逗号的写前面,且后面的每个字符都首字母大写
    

    相关文章

      网友评论

          本文标题:iOS-获取设备wifi 和Mac地址-获取info.plist

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