Deleting Rows

In editing mode, the red circles with the dash (shown in Figure 11.7) are deletion controls, and touching one should delete that row. However, at this point, touching a deletion control doesn’t delete anything. (Try it and see.) Before the table view will delete a row, it sends its data source a message about the deletion and waits for confirmation before pulling the trigger.

A UITableView asks its data source for the cells it should display when it is first loaded and at least three other times:

  • when the user scrolls the table view
  • when the table view is removed from the view hierarchy and then added back to the view hierarchy
  • when an object sends it the message reloadData

Now consider what would happen if deleting a row ...

Get iOS Programming: The Big Nerd Ranch Guide, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.