Hopefully this will be a quick fix. I have been trying to figure out the error that i keep getting. The error is listed below and the appdelagate is below that.
An
Like Sun Tzu said: it's best to win without fighting. In my case whenever I see this kind of error message (ie discrepancy between rows added deleted etc).. I don't even debug anything.. I simply avoid making that extra call where I reload the rows etc.. that's 99% of the cases where this error happens.
This is a common scenario where this bug happens: I have a UINavigationController
and it has a UITableView
, when I click on a row it pushes a new UITableView
and so on. This error always happens to me when I pop the last UITableview
and go back to the UITableView
before it, at this point I make an unnecessary call to the loadIt
function which basically inserts the rows and relaods the UITableView
.
The reason this happens is because I erroneously place my loadIt function in viewDidAppear:animated
rather than viewDidLoad
. viewDidAppear:animated
is called every time the UITableView
is displayed, viewDidLoad
is only called once.