Skip to content

Instantly share code, notes, and snippets.

@yurtaev
Created November 17, 2014 16:34
Show Gist options
  • Save yurtaev/50643030ec97f028834c to your computer and use it in GitHub Desktop.
Save yurtaev/50643030ec97f028834c to your computer and use it in GitHub Desktop.
public func getSSID() -> String? {
let interfaces:CFArray! = CNCopySupportedInterfaces()?.takeUnretainedValue()
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 dicRef:NSDictionary! = CNCopyCurrentNetworkInfo(interfaceName)?.takeUnretainedValue().__conversion()
if dicRef == nil { return nil }
let ssidObj:AnyObject? = dicRef[kCNNetworkInfoKeySSID]
if ssidObj == nil { return nil }
return ssidObj! as? String
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment