Creating the LocationDataManager class
Like 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 then click Next.
- Name this file
LocationDataManager
and click Create. - Click on
LocationDataManager.swift
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 thelocations
property may only be accessed by methods in this class. - Add...