今天做功能的时候遇到一个功能,需要获取手机当前WiFi的名称,后来上网找了找 方法:
导入库#import <SystemConfiguration/CaptiveNetwork.h>
编写方法:
- (NSString *)currentWifiSSID
{
NSString *ssid = nil;
NSArray *ifs = (__bridge id)CNCopySupportedInterfaces();
for (NSString *ifname in ifs) {
NSDictionary *info = (__bridge id)CNCopyCurrentNetworkInfo((__bridge CFStringRef)ifname);
if (info[@"SSIDD"])
{
ssid = info[@"SSID"];
}
}
return ssid;
}