Creating the LocationDataManager class
As what you've done in the previous chapter, you'll create a data manager class to load the location data from Locations.plist
and provide it to the LocationsViewController
instance for the Locations screen. The data will then be used to populate the table view in the Locations screen. Follow these steps:
- Right-click the
Model
folder in theLocation
folder and select New File. - iOS should already be selected. Choose Swift File and click Next.
- Name this file
LocationDataManager
and clickCreate
. - Click on the
LocationDataManager
file in the Project navigator and after theimport
statement, type in the following to declare theLocationDataManager
class:class LocationDataManager { }
- Inside the curly braces, add an array property,
locations
, to hold the list of locations:private var locations: [String] = []
The private
keyword means that the locations
property may only be accessed by methods in this class.