You will need to create some "editing" version of your internal data structure that you commit when the user finished editing. UITableView
does not keep track of where the cells are; it relies on you to do that. It just tells you when the user asks to move things. If you don't really want to move them at that point, then you'll need to keep track of where they really are versus the current order in the TableView.
Remember, UITableViews
are intentionally dumb. They don't keep track of data. They just draw things. You keep track of data (as the data source), and tell them what to draw when they ask.
I generally recommend that developers separate their actual data into a separate model class, and have the UITableView
maintain a separate NSMutableArray
based on that model class. In that case, during editing, you would update the UITableView
's array, and when finished editing, it would send that array to the model to update the "real" data.