ios - swift tableview is not reloading after deleting cell -
i have tableview created in storyboard . when try delete cell in tableview(_ tableview: uitableview, editactionsforrowat indexpath: indexpath) -> [uitableviewrowaction]
table not reloading after deleting. deleted in database also. when close view , come updated. going wrong?
func tableview(_ tableview: uitableview, editactionsforrowat indexpath: indexpath) -> [uitableviewrowaction]? { let deleteaction = uitableviewrowaction(style: .normal, title: "löschen") { (rowaction, indexpath) in let info: nsdictionary = self.finaltaskvalue[indexpath.item] as! nsdictionary let pwid = info["pwid"] as! string self.finaltaskvalue.remove(at: indexpath.row) self.finaltasktableview.beginupdates() self.finaltasktableview.deleterows(at: [indexpath], with: .none) self.finaltasktableview.endupdates() let url = url(string: "...php") var request = urlrequest(url: url!) request.httpmethod = "post" let body = "parameters" request.httpbody = body.data(using: .utf8) urlsession.shared.datatask(with: request) { data, response, error in if error == nil { dispatchqueue.main.async(execute: { do{ let json = try jsonserialization.jsonobject(with: data!, options: []) as? nsdictionary guard let parsejson = json else { print("") return } dispatchqueue.main.async(execute: { self.finaltasktableview.reloaddata() }) }catch { //print("caught error: \(error)") dispatchqueue.main.async(execute: { let message = "server ist offline! wir arbeiten mit hochdruck dran alles zu reparieren" } }) }else { dispatchqueue.main.async(execute: { let message = error!.localizeddescription } }.resume() } deleteaction.backgroundcolor = colordarkgreen return [deleteaction] }
1) have check tableview data final task value. 2) please when perform delete action don't use begin update , begin end update method please user reload method shown here.
finaltasktableview.reloaddata()
3) don't understand why define url request here? 4) request not using parameter of method or delete logic parameter not included. check request response fill again data want delete.
Comments
Post a Comment