导入头文件:
#import <SystemConfiguration/CaptiveNetwork.h>
- (void)currentWifiSSID {
// Does not work on the simulator.
NSArray *ifs = (__bridge id)CNCopySupportedInterfaces();
NSLog(@"ifs:%@",ifs);
for (NSString *ifnam in ifs) {
NSDictionary *info = (__bridge id)CNCopyCurrentNetworkInfo((__bridge CFStringRef)ifnam);
NSLog(@"dici:%@",[info allKeys]);
if (info[@"BSSID"]) {
ramcstr = info[@"BSSID"];
NSLog(@"%@",ramcstr);
}
if (info[@"SSID"]) {
rssidstr = info[@"SSID"];
NSLog(@"%@",rssidstr);
}
if (info[@"SSIDDATA"]){
SSIDDATAstr = info[@"SSIDDATA"];
NSLog(@"%@",SSIDDATAstr);
}
}
}
时间: 2024-11-09 20:57:04