iOS获取WiFi名称及路由器Mac地址

需要加入SystemConfiguration.framework


#import

#import


- (NSString *)getWiFiMac{

    NSString *ssid = @"Not Found";

    NSString *macIp = @"Not Found";

    CFArrayRef myArray =CNCopySupportedInterfaces();

    if (myArray != nil) {

        CFDictionaryRef myDict =CNCopyCurrentNetworkInfo(CFArrayGetValueAtIndex(myArray,0));

        if (myDict != nil) {

            NSDictionary *dict = (NSDictionary*)CFBridgingRelease(myDict);

            ssid = [dict valueForKey:@"SSID"];           //WiFi名称

            macIp = [dict valueForKey:@"BSSID"];     //Mac地址

        }

    }

    return macIp;

}

你可能感兴趣的:(iOS开发)