Hello everyone, I was watching The Card Game: Implementing the Protocols and Delegates Pattern (2020) - Lesson 23
I just can’t understand some things. Could someone help me understand them?
- About this line of code “collectionView.dataSource = self” and the like, you said, “Set the view controller as the datasource of the collection view”. Does that mean, the view controller is set as the object of the dataSource, i.e., the view controller is set as the delegate of the dataSource?
- Why do we have to write this code “collectionView.dataSource = self” and the like inside override func viewDidLoad() ?
- In the duqueueReusableCell method, there’s a parameter “indexPath”. This parameter specifies the location of the item or the cell. However, I don’t see any code that assign a value to that parameter. How can it know what cell or item we are talking about ?
- All the code is written inside the class of ViewController, but where is the object or instance of ViewController class ?