导入系统头文件
#import <SystemConfiguration/CaptiveNetwork.h>
实现代码
NSString *ssid = @"Not Found";
NSString *macIp = @"Not Found";
CFArrayRefmyArray = CNCopySupportedInterfaces();
if (myArray != nil) {
CFDictionaryRefmyDict = CNCopyCurrentNetworkInfo(CFArrayGetValueAtIndex(myArray, 0));
if (myDict != nil) {
NSDictionary *dict = (NSDictionary *)CFBridgingRelease(myDict);
ssid = [dict valueForKey:@"SSID"];
macIp = [dict valueForKey:@"BSSID"];
}
}
UIAlertView *av = [[UIAlertView alloc] initWithTitle:ssid message:macIp delegate:nil cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
[av show];