2017-02-12 48 views
1

列表中的所有可用的無線網絡SSID在swift3我試過,但我只得到連接的無線網絡SSID是可能可用的無線網絡SSID在swift3

func fetchSSIDInfo() -> String { 
    var currentSSID = "" 
    if let interfaces:CFArray = CNCopySupportedInterfaces() { 
     print(interfaces) 
     for i in 0..<CFArrayGetCount(interfaces){ 
      let interfaceName: UnsafeRawPointer = CFArrayGetValueAtIndex(interfaces, i) 
      let rec = unsafeBitCast(interfaceName, to: AnyObject.self) 
      let unsafeInterfaceData = CNCopyCurrentNetworkInfo("\(rec)" as CFString) 
      if unsafeInterfaceData != nil { 
       let interfaceData = unsafeInterfaceData! as Dictionary! 
       for dictData in interfaceData! { 
        if dictData.key as! String == "SSID" { 
         currentSSID = dictData.value as! String 
        } 
       } 
      } 
     } 
    } 
    return currentSSID 
} 

回答

0

的iOS只返回連接的SSID。無法在代碼中獲取其他SSID,既不是Swift也不是ObjectiveC。

0

根據Apple理念,您無法訪問硬件,因此您無法查詢低級別詳細信息:您所要求的內容Apple要求公開低級別調用,他們認爲這些調用並不安全。 而Yoy不能直接調用硬件,也不能寫驅動程序...

相關問題