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