ios - Adding row to Static UITableView: Invalid update: invalid number of rows in section 1 -


i'm trying programatically insert new row between 2 existing rows in static uitableview, crashes saying:

'invalid update: invalid number of rows in section 1. number of rows contained in existing section after update (6) must equal number of rows contained in section before update (6), plus or minus number of rows inserted or deleted section (1 inserted, 0 deleted) , plus or minus number of rows moved or out of section (0 moved in, 0 moved out).'

this code i'm using add new row

if (indexpath.section == 1 && indexpath.row == 3) {     // if first subtask want appear under sub tasks     if (subtaskrow.count == 0) {          tableview.insertrowsatindexpaths([nsindexpath(forrow: 5, insection: 1)], withrowanimation: .automatic)         // added first subtask         subtaskrow.addobject(5)         tableview.reloaddata()     // other sub tasks should appear below previous sub tasks     } else {         let row = (subtaskrow.lastobject as! int) + 1         tableview.insertrowsatindexpaths([nsindexpath(forrow: row, insection: 1)], withrowanimation: .automatic)         // keep track of subsequent subtasks         subtaskrow.addobject(row)         tableview.reloaddata()     } } 


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -