3
我试图从WCSession
获取最新数据,我无法理解为什么即使我刚刚收到了didReceiveApplicationContext
调用。 更多详细信息,请直接到代码:ApplicationContext属性总是返回一个空字典
//Watch Code
override func awakeWithContext(context: AnyObject?) {
super.awakeWithContext(context)
if (WCSession.isSupported()) {
session = WCSession.defaultSession()
session?.delegate = self
session?.activateSession()
verifyUser()
}
}
// 1. This function is called, with the applicationContext data
func session(session: WCSession, didReceiveApplicationContext applicationContext: [String : AnyObject]) {
print("CONTEXT \(applicationContext)")
}
// 2. I manually trigger this call from the watch with a button.
// even if I call this function after the previous function (1) it always print an Empty ([:]) applicationContext.
@IBAction func printContext(){
print(session?.applicationContext)
}
我希望applicationContext
财产与使用updateApplicationContext
,因为我总是使用与WCSession.defaultSession
同时为iOS和观察获得相同WCSession
集最新的信息不断更新应用程序。有什么我误解连接?!
so true .... :) – brush51