在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
1、导入库 import SystemConfiguration
import SystemConfiguration.CaptiveNetwork
2、方法 /// 获取wifi名称 /// /// - Returns: <#return value description#> func getUsedSSID() -> String { let interfaces = CNCopySupportedInterfaces() var ssid = "" if interfaces != nil { let interfacesArray = CFBridgingRetain(interfaces) as! Array<AnyObject> if interfacesArray.count > 0 { let interfaceName = interfacesArray[0] as! CFString let ussafeInterfaceData = CNCopyCurrentNetworkInfo(interfaceName) if (ussafeInterfaceData != nil) { let interfaceData = ussafeInterfaceData as! Dictionary<String, Any> ssid = interfaceData["SSID"]! as! String } } } return ssid }
SSID就是连接wifi的名称,直接使用即可,如果没读到,返回的空""
enjoy~ |
请发表评论