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
Modelfolder inside theLocationfolder and select New File. - iOS should already be selected. Choose Swift File and then click Next.
- Name this file
LocationItem. Click Create. TheLocationItemfile appears in the Project navigator. - Click the
LocationItemfile and add the following after theimportstatement to declare and define theLocationItemstructure:struct LocationItem...