我正在学习如何为 iPhone 应用程序创建配套的 Watch 应用程序。(一切都在模拟器上完成)
当我点击 Watch 应用程序上的按钮时,我正在发送消息。
session.sendMessage(["Message": "It Worked" ], replyHandler: nil) { (error) in
print(error)
}
然后我在 ViewController.swift 中收到消息:
func session(_ session: WCSession, didReceiveMessage message: [String : Any]) {
print(message["Message"])
print("!!!!")
theLabel.text = message["Message"] as! String
}
打印功能都不会触发。但是我知道我收到了消息,因为我的标签正在更新。断点在此函数中也不起作用。如果我在 didRecieveMessage 函数中调用另一个函数,它将触发。
这是一个错误吗?这让我觉得我的消息没有被发送很长时间,因为我只是想看看函数是否通过 print() 和断点触发。
如果不是错误,为什么 print() 不起作用?