1.首先需要导入系统库
import SystemConfiguration.CaptiveNetwork
2.使用方法,获得ssid和mac地址
func getMAC(){
let interfaces:NSArray = CNCopySupportedInterfaces()!
var ssid: String?
var mac: String?
for sub in interfaces
{
if let dict = CFBridgingRetain(CNCopyCurrentNetworkInfo(sub as! CFString))
{
ssid = dict["SSID"] as? String
mac = dict["BSSID"] as? String
}
}
}