'openParentApplication(_:reply:)' 已在此处明确标记为不可用 - Xcode 7 Beta
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30821219/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
'openParentApplication(_:reply:)' has been explicitly marked unavailable here - Xcode 7 Beta
提问by Aviv
After updating to Xcode 7 beta, I receive the following error message: "'openParentApplication(_:reply:)' has been explicitly marked unavailable here", when running the line of code "WKInterfaceController.openParentApplication"
更新到 Xcode 7 测试版后,我收到以下错误消息:“'openParentApplication(_:reply:)' 已在此处明确标记为不可用”,在运行代码行“WKInterfaceController.openParentApplication”时
Here is my actual code:
这是我的实际代码:
func getData(messageText: String) {
let infoDictionary = ["message" : messageText]
WKInterfaceController.openParentApplication(infoDictionary) {
(replyDictionary, error) -> Void in
if let castedResponseDictionary = replyDictionary as? [String: String],
responseMessage = castedResponseDictionary["message"]
{
print(responseMessage)
}
}
}
回答by Jeremy Huddleston Sequoia
+[WKInterfaceController openParentApplication:]is only relevant for WatchKit1 app extensions because with WatchKit1 app extensions, the appex is running on the phone instead of on the watch.
+[WKInterfaceController openParentApplication:]仅与 WatchKit1 应用扩展相关,因为对于 WatchKit1 应用扩展,appex 运行在手机上而不是手表上。
With WatchKit2 app extensions, the appex is running on the watch, so actions such as this are less trivial to accomplish. You probably want to use -[WCSession sendMessageData:replyHandler:errorHandler:]from WatchConnectivity.framework for what you're doing.
使用 WatchKit2 应用程序扩展,appex 在手表上运行,因此诸如此类的操作不太容易完成。您可能想要使用WatchConnectivity.framework 中的 -[WCSession sendMessageData:replyHandler:errorHandler:]来完成您正在做的事情。