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 for Bar 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 the System Item to Add:
- 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 to Action and Type to UIBarButtonItem...