0
我所擁有的是一個表格視圖,其中包含與其他正在與之聊天的人顯示不同消息的不同單元格。將單元格向左滑動時,出現Delete
選項。我希望能夠刪除單元格本身以及與Parse關聯的Room
。這是我到目前爲止有:在表格視圖單元格中單擊「刪除」時刪除關鍵字
func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
if editingStyle == UITableViewCellEditingStyle.Delete {
//Delete messages here
let query = PFQuery(className: "Message")
query.whereKey("Room", equalTo: ??????)
tableView.beginUpdates()
tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Automatic)
tableView.endUpdates()
}
}
該功能顯示Delete
選項,當我點擊它,我想將它刪除就被點擊的有誰知道查詢裏面所發生的細胞?我有一個Message
類,我想要刪除與我刪除的單元格關聯的Room
鍵。
在消息中的indexPath唯一一個?如果是這樣,你可以通過ObjectId找到ObjectInBackground。現在,您的結果只限於返回與房間名稱相同的房間。如果您不想刪除整個房間並且它是消息,而您只想刪除該房間中的特定消息,則必須按照上面提到的縮小範圍 – soulshined