Skip to content

Instantly share code, notes, and snippets.

@mlabraca
Created August 13, 2015 11:15
Show Gist options
  • Save mlabraca/f053f6dad8403f0cf809 to your computer and use it in GitHub Desktop.
Save mlabraca/f053f6dad8403f0cf809 to your computer and use it in GitHub Desktop.
Get Wifi network information in swift
import UIKit
import SystemConfiguration.CaptiveNetwork
class NetworkInfo {
func printSsidInfo {
if let ssidInfo = fetchSSIDInfo() as? [String:AnyObject], ssID = ssidInfo["SSID"] as? String {
println("SSID: \(ssID)")
} else {
println("SSID not found")
}
}
func fetchSSIDInfo() -> CFDictionary? {
if let
ifs = CNCopySupportedInterfaces().takeUnretainedValue() as? [String],
ifName = ifs.first,
info = CNCopyCurrentNetworkInfo((ifName as CFStringRef))
{
return info.takeUnretainedValue()
}
return nil
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment