I have a Split View application. When some data is input into fields in the Master View Controller I update the model (shared by Master and Detail View Controllers) and then Master VC asks Detail VC to update itself - Detail VC calls [self.tableView reloadData].
The first time the table draws the cells, everything is as expected. My problem is that after model changes and it performs another reloadData call, the old cells are not removed. Instead it adds more cells to the end of the table.
Let's say my array starts as {0,1,2}. The table draws cells 0, 1, 2. Model changes array to {0, 1 ,2b}. reloadData is called. Table draws cells 0, 1, 2, 0, 1, 2b. I would expect the initial 0,1,2 to have been deleted, but it isn't. Am I misunderstanding how reloadData works?
EDIT: I have no idea why, but I was utterly and completely convinced my model was fine. Thank you, KazR, for making me have a look. I was not clearing the arrays when updating them.
P.S. Can't find an option to pick answer, maybe those are "comments" and not "answers"?