前言:
項目中遇到了這個問題.記錄一下這個問題并不是針對iOS12才會出現(xiàn).而已升級了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;
}
發(fā)現(xiàn)Xcode10跑這一段代碼已經(jīng)獲取不到了..GG
解決辦法
WechatIMG2.jpeg
Access wifi information 設(shè)置為NO
到這里就好了.同志們趕緊去運行試試吧