Like you did in the previous chapter, you will create a data manager class to load the location data from Locations.plist and provide it to LocationsViewController. To create the data manager class, follow these steps:
- Right-click the Model folder in the Location folder and select New File.
- iOS should already be selected. Choose Swift File and click Next.
- Name this file LocationDataManager and click Create.
- After the import statement, type in the following to declare the LocationDataManager class:
class LocationDataManager {
}
- Inside the curly braces, add the following property 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.
- Now, add the following methods after the property declaration:
func fetch() {
for location in loadData...