ios - Deleting an object in a tableView cell from Parse -
i attempting delete objects parse. user able save posts , trying implement way them delete them. saved posts can found in tableview.
i have following.
override func tableview(tableview: uitableview, editactionsforrowatindexpath indexpath: nsindexpath) -> [uitableviewrowaction]? { let deleteaction = uitableviewrowaction(style: .default, title: "remove") { (action: uitableviewrowaction!, indexpath: nsindexpath!) -> void in let query = pfquery(classname: "savedobjects") query.orderbydescending("createdat") query.wherekey("savedbyuser", equalto: (pfuser.currentuser()?.username)!) query.findobjectsinbackgroundwithblock({ (objects : [pfobject]?, error: nserror?) -> void in if error == nil { object in objects! { object.deleteinbackground() } } }) self.tableview.reloaddata() } deleteaction.backgroundcolor = uicolor.redcolor() return [deleteaction] }
the object.deleteinbackground()
work, deletes objects saved user. delete object cell represents.
i have tried use object.deleteinbackgroundwithtarget([indexpath.row], selector: nil)
have had no luck.
if understood question correctly, think need add query.wherekey()
filtering objectid of corresponding row saved on parse. way call object.deleteinbackground()
delete cell selected tableview. hope helpful!
valerio
Comments
Post a Comment