I am trying to learn Xcode using iOS 14 Programming for Beginners. I have just entered the code to add the images and titles on the explore screen and have checked the code with the code written by the author and it is correct. When the Explore screen opens in the simulator it should show the images with titles on the screen. All that I get is the header at the top! I have checked the connection for the IBOutlets and the have the dot in the circle, so they are connected. The code builds OK, so I am not sure what is wrong? How can I find what is causing this problem? I have not mastered debugging yet, would this help?
Here is the ExploreCell.swift
// ExploreCellCollectionViewCell.swift
// EatOut
//
// Created by Tony Hudson on 02/06/2021.
//
import UIKit
class ExploreCell: UICollectionViewCell {
@IBOutlet weak var lblName: UILabel!
@IBOutlet weak var imgExplore: UIImageView!
}
Here is ExploreItem.swift
// ExploreItem.swift
// EatOut
//
// Created by Tony Hudson on 02/06/2021.
//
import Foundation
struct ExploreItem {
var name: String
var image: String
}
extension ExploreItem {
init(dict: [String:AnyObject]) {
self.name = dict["name"] as! String
self.image = dict["image"] as! String
}
}
Here is ExploreDataManager.swift
// ExploreDataManager.swift
// EatOut
//
// Created by Tony Hudson on 02/06/2021.
//
import Foundation
class ExploreDataManager {
fileprivate var items: [ExploreItem] = []
func fetch() {
for data in loadData() {
items.append(ExploreItem(dict: data))
}
}
fileprivate func loadData() -> [[String: AnyObject]] {
guard let path = Bundle.main.path(forResource: "ExploreData", ofType: "plist"), let items = NSArray(contentsOfFile: path) else {
return [[:]]
}
return items as! [[String: AnyObject]]
}
func numberOfItems() -> Int {
items.count
}
func explore(at index:IndexPath) -> ExploreItem {
items[index.item]
}
}
I think that is as much information that I can give! Can someone point me in the right direction so that I can solve this problem?