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

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -