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 NSError **)error NS_AVAILABLE_MAC(10_10);
并将 CWEventType 设置为:CWEventTypeSSIDDidChange
它说它需要权利,但我无法在我的 Mac 上运行它。错误信息是:
该应用程序意外退出。来自调试器的消息:由于代码签名错误而终止。
我的权利文件(我怀疑问题出在哪里)是这样的:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.wifi.events</key>
<true/>
</dict>
</plist>
我在目标的构建设置中设置代码签名路径。说到这一点,如果我排除本地权利文件,应用程序会运行但不会按预期运行。正在研究的 API 返回一个错误对象,描述如下:
Error Domain=com.apple.wifi.request.error Code=4 "The operation couldn’t be completed. (com.apple.wifi.request.error error 4.)"
这绝对是一个头脑扭曲,或者至少我希望不是这样,否则我就是个白痴。我在会员中心有我的应用程序的特定应用程序 ID,以及特定的开发配置文件(尽管我不应该这样做,因为我使用的是通配符开发配置文件)。
提前致谢。