2013-03-05 55 views
3

我正在使用CNCopySupportedInterfaces()獲取bssid並且它不返回任何值。不知道爲什麼。CNCopySupportedInterfaces()雖然無線連接返回沒有值

我的代碼如下所示:

#import <SystemConfiguration/CaptiveNetwork.h> 

    CFArrayRef myArray = CNCopySupportedInterfaces(); 
    CFDictionaryRef myDict = CNCopyCurrentNetworkInfo(CFArrayGetValueAtIndex(myArray, 0)); 
    NSLog(@"Connected at:%@",myDict); 
    NSDictionary *myDictionary = (__bridge_transfer NSDictionary*)myDict; 
    NSString * BSSID = [myDictionary objectForKey:@"BSSID"]; 
    NSLog(@"bssid is %@",BSSID); 

的NSLog(@ 「%@」,CNCopySupportedInterfaces());

回報(null)

不知道哪裏出了什麼問題?需要一些指導

回答

4

只是想通了它,這段代碼在ios6中無法正常工作。在ios5中正常工作..它在模擬器中不起作用。嘗試在設備中。

+1

Works在我的iOS 6和iOS 7(beta)設備上爲我找到。不在模擬器中。 – Henning 2013-09-06 18:01:40

+0

dun使用模擬器。這需要使用設備。 – lakesh 2013-09-07 10:46:35

+0

我使用iPhone 5S操作系統7.1它不工作, CNCopyCurrentNetworkInfo(CFArrayGetValueAtIndex(myArray,0))返回null – vualoaithu 2014-04-17 08:05:08