Adding items to the list
To add items, we will need to add a new bar button to our navigation bar and set up a tap handler on the button so that we can respond to it by showing an input dialog to the user to enter the name of the item they want to add. To do so, we need to perform the following steps:
- Open up our
Main.storyboard
, search forBar Button Item
from the Object library, and drag it to the right-hand side of the navigation bar:

- Select the
Bar Button Item
and change theSystem Item
toAdd
:
- Click the
Assistant Editor
to open the source code for our Table View Controller side-by-side with the storyboard:

- Control click on the add button (
+
) and drag into into your source code file where there is a blank line outside of any method and leave it:

- You will then see a modal where you need to change the
Connection
toAction
andType
toUIBarButtonItem
. In theName
field, give your method a name. I called minedidSelectAdd
:

This will add a method to your controller with the following signature...