I am trying to learn Xcode using iOS 14 Programming for Beginners.
I have just created a new View Controller and created a Cocoa Touch class called RestaurantListViewController. In this I had to add 2 collection view stubs and an @IBoutlet var to the UICollectionView.
The book then instructs me to click on th View Controller in the
document outline, for the view controller I have just created, the click on the Identity Inspector to add the class, but it says no selection?
I can't see where I am going wrong?
The only warning I get is: Prototype collection view cells must have reuse indentifiers.
Here is the code for the class:
Please can someone help?
I have just created a new View Controller and created a Cocoa Touch class called RestaurantListViewController. In this I had to add 2 collection view stubs and an @IBoutlet var to the UICollectionView.
The book then instructs me to click on th View Controller in the
document outline, for the view controller I have just created, the click on the Identity Inspector to add the class, but it says no selection?
I can't see where I am going wrong?
The only warning I get is: Prototype collection view cells must have reuse indentifiers.
Here is the code for the class:
Code Block // // RestaurantListViewController.swift // EatOut // // Created by Tony Hudson on 22/05/2021. // import UIKit class RestaurantListViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate { @IBOutlet weak var collectionView: UICollectionView! override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. } func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { 1 } func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { return collectionView.dequeueReusableCell(withReuseIdentifier: "restaurantCell", for: indexPath) } }
Please can someone help?
I find that the book does not explain the methods very well. The book said 'Click on Main.storyboard and click on View Controller icon of the newly added View Controller Scene in the document outline'. It did not say anything about clicking on the new scene tab bar as you described. this is not the first instruction that the author has described ambiguously,
Thank you for your help!
Thank you for your help!