本文实例为大家分享了iOS获取当前连接wifi信息的具体代码,供大家参考,具体内容如下
导入框架CaptiveNetwork
1
|
#import <SystemConfiguration/CaptiveNetwork.h> |
获取当前连接的wifi信息
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
// 只能获取当前的SSID - (id)fetchSSIDInfo { NSString *currentSSID = @ "" ; CFArrayRef myArray = CNCopySupportedInterfaces(); if (myArray != nil){ NSDictionary* myDict = (__bridge NSDictionary *) CNCopyCurrentNetworkInfo(CFArrayGetValueAtIndex(myArray, 0)); if (myDict!=nil){ currentSSID=[myDict valueForKey:@ "SSID" ]; } else { currentSSID=@ "<<NONE>>" ; } } else { currentSSID=@ "<<NONE>>" ; } NSArray *ifs = (__bridge id)CNCopySupportedInterfaces(); NSLog(@ "%s: Supported interfaces: %@" , __func__, ifs); id info = nil; for (NSString *ifnam in ifs) { info = (__bridge id)CNCopyCurrentNetworkInfo((CFStringRef)CFBridgingRetain(ifnam)); if (info && [info count]) { break ; } } NSLog(@ "wifi info %@" ,info); return info; } |
1
2
3
4
5
|
wifi info { BSSID = "a4:2b:8c:92:47:3c" ; SSID = "XF-WORLD" ; SSIDDATA = <58462d57 4f524c44>; } |
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持服务器之家。
原文链接:https://www.cnblogs.com/wuotto/archive/2018/07/23/9354345.html