

Even though this would work just fine, it would severely limit and slow us down as the application gains in complexity.įor the shopping list application, we're going to create a custom model class. The most obvious choice is to store the item's properties in a dictionary. How are we going to work with items in the shopping list application? In other words, what type of object do we use to store the properties of an item, such as its name, price, and a string that uniquely identifies each item?

You should see an empty table view with a navigation bar at the top and a tab bar at the bottom.
#Swift share menu simulator
Run the application in the simulator to see if everything is set up correctly. Select the table view of the list view controller and set Prototype Cells in the Attributes Inspector to 0. Select the list view controller and choose Embed In > Navigation Controller from the Editor menu. The list view controller needs to be the root view controller of a navigation controller. Select the tab bar controller, open the Attributes Inspector, and make it the storyboard's initial view controller by checking the checkbox Is Initial View Controller. Drag a UITableViewController from the Object Library, set its class to ListViewController in the Identity Inspector, and create a relationship segue from the tab bar controller to the list view controller. Drag a UITabBarController instance from the Object Library and delete the two view controllers that are linked to the tab bar controller. Open Main.storyboard, select the view controller that's already present, and delete it. Leave the checkbox Also create XIB file unchecked and make sure Languages is set to Swift. Tell Xcode where you want to save the class and click Create. Name the class ListViewController and make it a subclass of UITableViewController. Select Cocoa Touch Class from the iOS > Source section. Create a new class by selecting New > File. from the File menu.

2. Creating the List View ControllerĪs you might have expected, the list view controller is going to be a subclass of UITableViewController. Make sure the checkboxes at the bottom are unchecked. Tell Xcode where to save the project and click Create. Set Language to Swift and Devices to iPhone. Name the project Shopping List and enter an organization name and identifier. Launch Xcode and create a new project based on the Single View Application template in the iOS > Application section. Seeding an application with data is often a good idea to help new users get up to speed quickly.
#Swift share menu how to
In this lesson, I also show you how to seed the shopping list application with dummy data to give new users something to start with. What type of store do we use to store the list of items? Can the user add, edit, and delete items? These are questions that we address in the next two lessons. In this lesson, we focus on the first feature. In the next lesson, we the finishing touches on this feature and zoom in on the shopping list, the application's second feature.Įven though the shopping list application isn't complicated from a user's perspective, there are several decisions that need to be made during its development. We'll build the application with a tab bar controller to make switching between the two views fast and straightforward. The shopping list application we're about to create has two features, managing a list of items and creating a shopping list by selecting items from the list.

We've got a lot of ground to cover so let's get started. Along the way, you'll also learn a number of new concepts and patterns, such as creating a custom model class and implementing a custom delegate pattern.
#Swift share menu series
In the next two lessons, we'll put what we learned in this series into practice by creating a shopping list application.
