Configuring data source methods for the collection view
When your app is running, an instance of the ExploreViewController
class acts as the view controller for the Explore screen. It is responsible for loading and displaying all the views in that screen, including the collection view you added earlier. The collection view needs to know how many collection view cells to display and what to display in each cell. Normally, the view controller is responsible for providing this information. Apple has already created a protocol, UICollectionViewDataSource
, for this purpose. All you need to do is connect the collection view's dataSource
outlet to the ExploreViewController
class and implement the required methods of this protocol.
The collection view also needs to know what to do if the user taps on a collection view cell. Again, the view controller for the collection view is responsible, and Apple has created the UICollectionViewDelegate
protocol for this purpose. You will connect...