[英]How do I swipe to delete table cell to update on parse?
I am able to delete the row in my tableview. 我可以删除表格视图中的行。 But I would like to do the same for the information on parse.com.
但是我想对parse.com上的信息也做同样的事情。 any suggestions as to how I could go about this?
关于如何解决这个问题有什么建议吗?
override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
if editingStyle == UITableViewCellEditingStyle.Delete {
// Delete the row from the data source
tableView.beginUpdates()
usernames.removeAtIndex(indexPath.row)
tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
tableView.endUpdates()
} else if editingStyle == .Insert {
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
}
}
假设usernames
是PFObject(也许是PFUser)的数组,那么您只需要在tableView.beginUpdates()
之后添加usernames[indexPath.row].deleteInBackground()
tableView.beginUpdates()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.