ios – ‘openParentApplication(_:reply :)’已被显式标记为不可用 – Xcode 7 Beta

更新到 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:]来做你正在做的事情.

相关文章

当我们远离最新的 iOS 16 更新版本时,我们听到了困扰 Apple...
欧版/美版 特别说一下,美版选错了 可能会永久丧失4G,不过只...
一般在接外包的时候, 通常第三方需要安装你的app进行测...
前言为了让更多的人永远记住12月13日,各大厂都在这一天将应...