更新到
Xcode 7 beta后,我收到以下错误消息:“’openParentApplication(_:reply :)’已被显式标记为不可用在这里”,当运行代码行“WKInterfaceController.openParentApplication”
这是我的实际代码:
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)
}
}
}
解决方法
+[WKInterfaceController openParentApplication:]仅与WatchKit1应用程序扩展程序相关,因为使用WatchKit1应用程序扩展名,appex正在手机上运行,而不是在手表上运行.
通过WatchKit2应用程序扩展,appex在手表上运行,因此这样的操作不太简单.你可能想要使用WatchConnectivity.framework的-[WCSession sendMessageData:replyHandler:errorHandler:]来做你正在做的事情.