mirror of
https://github.com/tappollo/OSCKit.git
synced 2026-04-26 10:55:39 +08:00
29 lines
787 B
Swift
29 lines
787 B
Swift
//
|
|
// SSID.swift
|
|
// Pods
|
|
//
|
|
// Created by Zhigang Fang on 5/15/17.
|
|
//
|
|
//
|
|
|
|
import Foundation
|
|
import SystemConfiguration.CaptiveNetwork
|
|
|
|
extension OSCKit {
|
|
|
|
public var currentSSID: String? {
|
|
if let interfaces = CNCopySupportedInterfaces() {
|
|
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 let interfaceData: NSDictionary = unsafeInterfaceData, let ssid = interfaceData["SSID"] as? String {
|
|
return ssid
|
|
}
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
}
|