I\'m using the code below to delete a row in my tableview. First I delete the object from my array and then from the tableview using this code:
let i = IndexPath
I'm not sure about from where you get your var rowNum
, but to me this issue looks like something similar it already happened to me.
For me the problem was that passing to the cell the indexPath
in the tableView: cellForRowAt indexPath:
was causing this value to be not updated when a cell was deleted.
in other words, all the buttons that are ordered after the button of the deleted cell must have their index shifted by -1, or they will delete the row n+1.
row A index 0
row B index 1
row C index 2
row D index 3
deleting B it happens
row A index 0
row C index 2
row D index 3
while C should have index 1 and D should have index 2. In this case tapping the button to delete C will cause D to be deleted, and tapping the button to delete D will cause a crash.
I hope I was clear enough.