1.import SystemConfiguration.CaptiveNetwork
// 獲取當(dāng)前wifi名稱
func getWifiName() -> String? {
? ? ? ? let interfaces: CFArray! = CNCopySupportedInterfaces()
? ? ? ? if interfaces == nil { return nil }
? ? ? ? let if0: UnsafePointer? = CFArrayGetValueAtIndex(interfaces, 0)
? ? ? ? if if0 == nil { return nil }
? ? ? ? let interfaceName: CFStringRef = unsafeBitCast(if0!, CFStringRef.self)
? ? ? ? let dictionary = CNCopyCurrentNetworkInfo(interfaceName) as NSDictionary?
? ? ? ? if dictionary == nil { return nil }
? ? ? ? return dictionary?[kCNNetworkInfoKeySSID as String] as? String
? ? }
