Apple似乎在Yosemite和CoreWLAN框架上引入了相当大的变化.我想使用它的新API,引用头文件:
/*!
* @method
*
* @param type
* A CWEventType value.
*
* @param error
* An NSError object passed by reference, which upon return will contain the error if an error occurs.
* This parameter is optional.
*
* @result
* A BOOL value indicating whether or not an error occurred. YES indicates no error occurred.
*
* @abstract
* Register for specific Wi-Fi event notifications.
*
* @discussion
* Requires the <i>com.apple.wifi.events</i> entitlement.
*/
- (BOOL)startMonitoringEventWithType:(CWEventType)type error:(out …Run Code Online (Sandbox Code Playgroud) 我正在编写一个OS X应用程序,它取决于确定无线信号强度的能力,但我无法弄清楚用于沙箱的权利.
每当我使用
NSMutableArray *scanResults;
CWInterface *currentInterface = [CWInterface interface];
NSLog(@"currInterface: %@\n", currentInterface);
NSMutableDictionary *signalsDict = [[NSMutableDictionary alloc] init];
NSError *err = nil;
scanResults = [NSMutableSet setWithSet:[currentInterface scanForNetworksWithSSID:nil error:&err]];
Run Code Online (Sandbox Code Playgroud)
The operation couldn't be completed. (com.apple.coreWLAN.error error 1.)尽管在XCode中检查了所有权利,但我收到了错误.我遗失了哪些权利?
CoreWLANWirelessManager示例项目具有相同的问题.
我正在寻找一种方法来从我的IOS-app扫描可用的Wi-Fi接入点(热点).
我所需要的只是热点名称的活动列表,设备可以连接到该列表.就像Safari在我们启动或激活它时显示Wi-Fi热点列表一样.
我想在App Store上发布应用程序,所以我不能使用任何类型的私有API(对吧?).不幸的是CoreWLAN.framework不适用于IOS(对吧?).
那么,有可能实现我的目标吗?我可以通过某种方式收集可用的接入点名称(SSID)吗?
我正在尝试显示所有可用的 WIFI 连接。它不起作用。这是我的代码:
import Foundation
import CoreWLAN
var cwInterface = CWInterface()
do {
let routers = try cwInterface.scanForNetworksWithSSID(nil)
print(routers)
} catch let error as NSError {
print("Error: \(error.localizedDescription)")
}
Run Code Online (Sandbox Code Playgroud)
我没有得到任何结果。我做错了什么?