ios - EXC_BAD_ACCESS when I'm trying to delete a UITableView sections -
i have code:
// - update data source self.order.persons.removeatindex(index) // - disable user interaction self.tableview.userinteractionenabled = false // - delete needed section table view let sectionindexset = nsindexset(index: self.order.persons.count - 1) self.tableview.beginupdates() self.tableview.deletesections(sectionindexset, withrowanimation: .automatic) self.tableview.endupdates() // - update table view delay update indexes nstimer.scheduledtimerwithtimeinterval(0.3, handler: { self.tableview.userinteractionenabled = true self.tableview.reloaddata() })
so problem:
case 1: when on visible zone of table view sections, not 1 want delete, works great.
case 2: when on visible zone of table view section want delete, debugger stop @ line:
self.tableview.endupdates()
and gives errors :
thread 1: exc_bad_access (code=1, address=0x0).
i don't understand why case 1 working great, case 2 not. information, use reusable cells.
you removing different data source , in tableview
issue
// - delete needed section table view let sectionindexset = nsindexset(index: self.order.persons.count - 1)
fix should
// - delete needed section table view let sectionindexset = nsindexset(index: index)
Comments
Post a Comment