Declaring the RestaurantListViewController class

As you did in the previous chapter, you'll add a new Cocoa Touch Class file to your project, but this time, it will be used to implement the RestaurantListViewController class. Follow these steps:

  1. Click the Navigator and Inspector buttons to turn on the Navigator and Inspector areas.
  2. Right-click on the LetsEat group and choose New Group from the pop-up menu.

  1. Name this new group Restaurants. If you make a mistake, click the name and press Return on your keyboard to make it editable again.
  1. Right-click the Restaurants group and select New File...:
  2. iOS should already be selected. Select Cocoa Touch Class and click Next.
  1. The Choose options for your new file screen window will appear. Type the following into the Class and Subclass of fields:
  • Class: RestaurantListViewController
  • Subclass of: UIViewController

Click Next when you're done.

  1. On the next screen, click Create.
  1. Now, the RestaurantListViewController.swift file has been added to the project, and you will see the boilerplate code for the RestaurantListViewController class in it. The RestaurantListViewController class is a subclass of UIViewController and contains a single method, viewDidLoad(). Like you did previously, remove all the extra code in the RestaurantListViewController class until only the code shown in the following screenshot remains:


As you did before for ExploreViewController, you'll make RestaurantListViewController the view controller for the view in the view controller scene and adopt the collection view data source and delegate protocols. Now, you need to add an outlet for the collection view manually in the class definition and use the Connections inspector to connect the outlet to the collection view in the storyboard. You'll do this in the next section.

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

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