Adding Rows

There are two common interfaces for adding rows to a table view at runtime.

  • A button above the cells of the table view: usually for adding a record for which there is a detail view. For example, in the Contacts app, you tap a button when you meet a new person and want to take down his or her information.

  • A cell with a green plus sign: usually for adding a new field to a record, such as when you want to add a birthday to a person’s record in the Contacts app. In editing mode, you tap the green plus sign next to add birthday.

In this exercise, you will use the first option and create a New button in the header view. When this button is tapped, a new row will be added to the UITableView.

In ItemsViewController.swift ...

Get iOS Programming: The Big Nerd Ranch Guide 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.