Moving Rows
To change the order of rows in a UITableView, you will use another method from the UITableViewDataSource protocol – tableView:moveRowAtIndexPath:toIndexPath:.
To delete a row, you had to send the message deleteRowsAtIndexPaths:withRowAnimation: to the UITableView to confirm the deletion. Moving a row, however, doesn’t require confirmation; the table view moves the row on its own authority and sends the data source the message tableView:moveRowAtIndexPath:toIndexPath: to report the move. You just have to catch this message to update your data source to match the new order.
But before we can implement the data source method, we need to give the PossessionStore a method to change the order of Possessions in its allPossessions array. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access