在我的應用程序中,我使用Parse SDK從數據庫中獲取藥品和金額列表,並將其通過iPhone傳遞到手錶。我手錶上的兩個獨立的sendMessages在WillActivate()來實現:使用解析在WatchOS中準備行
let iNeedMedicine = ["Value": "Query"]
session.sendMessage(iNeedMedicine, replyHandler: { (content:[String : AnyObject]) -> Void in
if let medicines = content["medicines"] as? [String] {
print(medicines)
self.table.setNumberOfRows(medicines.count, withRowType: "tableRowController")
for (index, medicine) in medicines.enumerate() {
let row = self.table.rowControllerAtIndex(index) as? tableRowController
if let row1 = row {
row1.medicineLabel.setText(medicine)
}
}
}
}, errorHandler: { (error) -> Void in
print("We got an error from our watch device : " + error.domain)
})
二:
let iNeedAmount = ["Value" : "Amount"]
session.sendMessage(iNeedAmount, replyHandler: { (content:[String : AnyObject]) -> Void in
if let quantity = content["quantity"] as? [String] {
print(quantity)
self.table.setNumberOfRows(quantity.count, withRowType: "tableRowController")
for (index, quant) in quantity.enumerate() {
let row = self.table.rowControllerAtIndex(index) as? tableRowController
row!.amountLabel.setText(quant)
}
}
}, errorHandler: { (error) -> Void in
print("We got an error from our watch device : " + error.domain)
})
我所得到的是這樣的:Problem。是因爲兩個不同的信息?
是,所述第二消息的回覆是覆蓋第一個表。你想達到什麼目的?在一張桌子上顯示藥物和金額? – joern