iOS 获取WIFI SSID及MAC地址

    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"];

            macIp = [dict valueForKey:@"BSSID"];

        }

    }

    UIAlertView *av = [[UIAlertView alloc] initWithTitle:ssid

                                                 message:macIp

                                                delegate:nil

                                       cancelButtonTitle:nil

                                       otherButtonTitles:@"OK", nil];

    [av show];

posted @ 2016-01-29 11:44  懒懒初阳  阅读(642)  评论(0编辑  收藏  举报