我正在使用 CoreWLan 为 OSX/Cocoa 编程。当我尝试使用CWInterface的scanForNetworksWithName方法时,它总是返回一个空的网络列表。
我已经在 StackOverflow 和其他地方阅读了大量关于如何使用此方法的帖子,看起来我没有做错任何事情。有人能指出我错过了什么吗?
我的操作系统是优胜美地 10.10.3。我的代码如下:
NSArray *networks = [[currentInterface scanForNetworksWithName:nil error:nil] allObjects];
for (CWNetwork *network in networks) {
// code do not enter here, as networks is always empty, even with
// several SSID's appearing in my list of WiFi connections
}