Passing data to the RestaurantDetailViewController instance
You have added and connected the outlets for the Restaurant Detail screen inside the RestaurantDetailViewController
class. You've also added code to this class to get restaurant data from a RestaurantItem
instance and use it to populate its outlets. The last thing you need to do is pass the selected RestaurantItem
instance from the RestaurantListViewController
instance to the RestaurantDetailViewController
instance. Follow these steps:
- Click
RestaurantListViewController.swift
in the Project navigator. - Add the following code after
viewDidLoad()
to call ashowRestaurantDetail(segue:)
method if the segue identifier isshowDetail
:override func prepare(for segue:UIStoryboardSegue, sender:Any?) { if let identifier = segue.identifier { switch identifier { ...