首先添加框架:SystemConfiguration.framework
然后引用
#import <SystemConfiguration/CaptiveNetwork.h>具体方法的实现 (注意:模拟器是获取不到的,只有在真机上跑才可以!)
- (NSString *) getDeviceSSID
{
NSArray *ifs = (__bridge id)CNCopySupportedInterfaces();
id info = nil;
for (NSString *ifnam in ifs) {
info = (__bridge id)CNCopyCurrentNetworkInfo((__bridgeCFStringRef)ifnam);
if (info && [info count]) {
break;
}
}
NSDictionary *dctySSID = (NSDictionary *)info;
NSString *ssid = [[dctySSID objectForKey:@"SSID"] lowercaseString];
return ssid;
}
原文出自:http://blog.163.com/l1_jun/blog/static/1438638820121016102025262/