Reputation: 2298
The UITableView
's data source is from an external server. Anyone could update / delete / add data to it at any time.
The problem is that UITableView
likes to complain whenever data is not consistent:
The number of rows contained in an existing section after the update (X) must be equal to the number of rows contained in that section before the update (Y), plus or minus the number of rows inserted or deleted from that section and plus or minus the number
How do I create a UITableView
that lets me delete, add, update and refresh without having to be consistent?
I use Swift 3.
Upvotes: 0
Views: 347
Reputation: 131416
"How do I create a UITableView
that lets me delete, add, update, and refresh without having to be consistent?"
You don't. The model data presented in the table view must match the table view itself. If you delete cells from the table view, you have to delete those entries in your model so that when the table view asks the data source for info on your rows/sections, they match.
You should cache your server data locally and use it to populate the table view. If the user makes a change to the local copy, you should batch-update the server with your changes.
Likewise, if the server updates the data, you should batch-update the local copy and then tell the table view to reload it's contents.
It's hard to give a specific answer without a more specific description of what you're trying to do.
Upvotes: 1