Reputation: 767
The actual issue is that the data I am getting is from an NSSet and when I change the set, since it is unordered, the final entry is not always the same or the last object I added to the set. So, when I call reloadData (and with a breakpoint I can tell it is only updating/adding the last cell in the table because the number of rows has increased by 1) it often finds the wrong entry to add to the new cell and I end up with duplicates and with my new object not appearing in the table.
Is this the correct behavior for reloadData? And if so, what should I be using instead to make sure all the data appears? Should I just delete all the rows and start over or is there a way to just update the properties of the rows already there?
Edit: I suppose I was unclear, prior to feeding the data to the tableView, I convert it to an array but the array is never in the same order due to the nature of a set. It was suggested that I order the array but even if I did that, the new item would not appear if it was not the last item in the order.
Upvotes: 0
Views: 124
Reputation: 842
You shouldn't use an NSSet
to feed a UITableView
. Since NSSet
is not ordered with indexes, UITableView
won't behave properly. Try to switch to NSArray
which has object indexes.
Upvotes: 1