import "ViewController.h"
import "SystemConfiguration/CaptiveNetwork.h"
@interface ViewController ()
@end
@implementation ViewController
-
(void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.NSLog(@"😂😂😂😂你连接的WIFI名字是:%@", [self getCurrentSSID]);
} (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (NSString *) getCurrentSSID
{
NSArray *ifs = (__bridge id)CNCopySupportedInterfaces();
id info = nil;
for (NSString *ifnam in ifs)
{
info = (__bridge id)CNCopyCurrentNetworkInfo((__bridge CFStringRef)ifnam);
if (info && [info count])
{
break;
}
}
NSString *ssid = [NSString stringWithFormat:@"%@",[info objectForKey:@"SSID"]] ;
return ssid;
}
@end