To get our data out of the plist, add the following method above loadData()
inside of our ExploreDataManager
:
func fetch() { for data in loadData() { print(data) } }
Our fetch()
method is going to loop through our dictionary data from the plist. Here is what your file should look like now:
Inside of your ExploreViewController.swift
file, delete the previous print
statement that was inside of your viewDidLoad()
and replace it with the following:
let manager = ExploreDataManager() manager.fetch()
Let's build and run the project by hitting the Play button (or use cmd+ R). You will notice that, in the Debug
panel, every time our loop runs, it gives a dictionary object, such as the following:
This is exactly what we want.
Now, inside of ExploreDataManager
, add the following directly above our fetch
method:
fileprivate var items:[ExploreItem] = []
Next, inside of our fetch()
, update our for...in
loop by replacing print(data)
with the following:
items.append(ExploreItem(dict: data))
Your...