func getSSID() -> String? {
let interfaces: CFArray! = CNCopySupportedInterfaces()?.takeRetainedValue()
if interfaces == nil { return nil }
let if0: UnsafePointer<Void>? = CFArrayGetValueAtIndex(interfaces, 0)
if if0 == nil { return nil }
let interfaceName: CFStringRef = unsafeBitCast(if0!, CFStringRef.self)
let dictionary = CNCopyCurrentNetworkInfo(interfaceName)?.takeRetainedValue() as NSDictionary?
if dictionary == nil { return nil }
return dictionary?[kCNNetworkInfoKeySSID as String] as? String
}
- -
项目中遇到了 那就随手记一下