前言:
项目中遇到了这个问题.记录一下这个问题并不是针对iOS12才会出现.而已升级了Xcode10才会有..哈哈
原获取wifi名代码
//引入头
#import <SystemConfiguration/CaptiveNetwork.h>
+ (NSString *)getWifiName{
NSString *wifiName = nil;
CFArrayRef wifiInterfaces = CNCopySupportedInterfaces();
NSArray *interfaces = (__bridge NSArray *)wifiInterfaces;
for (NSString *interfaceName in interfaces) {
CFDictionaryRef dictRef = CNCopyCurrentNetworkInfo((__bridge CFStringRef)(interfaceName));
if (dictRef) {
NSDictionary *networkInfo = (__bridge NSDictionary *)dictRef;
wifiName = [networkInfo objectForKey:(__bridge NSString *)kCNNetworkInfoKeySSID];
CFRelease(dictRef);
}
}
CFRelease(wifiInterfaces);
return wifiName;
}
发现Xcode10跑这一段代码已经获取不到了..GG
解决办法
Access wifi information 设置为NO
到这里就好了.同志们赶紧去运行试试吧