废话不说,直接上代码:
private func fetchNetInfo() -> [String : AnyObject]{
let interfaceNames = CNCopySupportedInterfaces()
var SSIDInfo = [String : AnyObject]()
guard interfaceNames != nil else {
return SSIDInfo
}
for interface in interfaceNames as! [CFString] {
print("Looking up SSID info for \(interface)") // en0
if let info = CNCopyCurrentNetworkInfo(interface as CFString){
SSIDInfo = info as! [String : AnyObject]
}
for d in SSIDInfo.keys {
print("\(d): \(SSIDInfo[d]!)")
}
if SSIDInfo.count > 0{
break
}
}
return SSIDInfo
}
需要注意的是,iOS12以后 需要在xcode设置一下
注意:此时你的应用证书需要重新生成一下。
|
请发表评论