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
:
- 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:
This will add a method to your controller with the following signature...