Hooking up our outlets

Let's now link our file, RestaurantViewController, to our new UIViewController in the storyboard:

  1. Select the UIViewController with the Collection View that we just created.
  2. In the Utility panel, select the Identity inspector. Under Custom Class, in the Class drop-down menu, select RestaurantViewController and hit the Enter key.
  3. Select the Connections Inspector in the Utilities Panel.
  4. Under Outlets, (just like we did earlier) click on the collectionView circle and drag from the circle to the Collection View that we just added inside of your UIViewController.

Now that we have our Collection View hooked up, we need to hook up the data source and delegate. The data source and delegate allow us to pass data to our Collection View as well as to know when our Collection View has some interaction. Let's do that now by doing the following:

  1. In your scene, select your Collection View. In your Utilities Panel, select the Connections Inspector.
  2. Click on and drag the dataSource property to the Restaurant View Controller in your Outline view.
  3. Click on and drag the delegate property to the Restaurant View Controller in your Outline view.

Finally, let's set up our cell to have a color.

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

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