Setting the delegate and data source properties of the collection view

ExploreViewController will provide the data that the collection view will display, as well as the methods that will be executed when the user interacts with the collection view. You need to connect the collection view's data source and delegate outlets to ExploreViewController for this to work. Follow these steps to do so:

  1. Click the Navigator and Inspector buttons to display the Navigator and Inspector areas again if you haven't done so already.
  1. Main.storyboard should still be selected. Click the Collection View for the Explore View Controller Scene in the document outline to select it. Click the Connections inspector. Look at the Outlets section. Note that there are two empty circles next to the dataSource and delegate outlets. Drag from each empty circle to the ExploreViewController icon in the document outline, as shown in the following screenshot:

  1. The dataSource and delegate properties of Collection View have been connected to ExploreViewController:

Now, you will add some code to make ExploreViewController conform to the collection view data source protocol, and tell the collection view to display 20 collection view cells when you run your app.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.220.64.128