Storing a user-selected location
At present, the LocationDataManager
class loads data from Locations.plist
and stores location information in an array of strings. You will create a new structure, LocationItem
, and configure the LocationDataManager
class to store locations in an array of LocationItem
instances. After that, you'll modify the LocationViewController
class so that it can store a LocationItem
instance containing the user-selected location. You can then pass this instance to the RestaurantListViewController
instance in your app. Follow these steps:
- Right-click on the
Model
folder inside theLocation
folder and select New File. - iOS should already be selected. Choose Swift File and then click Next.
- Name this file
LocationItem
. Click Create. TheLocationItem
file appears in the Project navigator. - Click the
LocationItem
file and add the following after theimport
statement to declare and define theLocationItem
structure:struct LocationItem { ...