Passing data from RestaurantListViewController to RestaurantDetailViewController

So far, you have added and connected the outlets for the Restaurant Detail screen inside RestaurantDetailViewController. You've also added code to get restaurant data from a RestaurantItem instance and used it to populate the outlets. The last thing you need to do is pass the selected RestaurantItem instance from RestaurantListViewController to RestaurantDetailViewController.

To do this, do the following steps:

  1. Click RestaurantListViewController.swift in the Project navigator.
  2. Add the following code under viewDidLoad():
override func prepare(for segue:UIStoryboardSegue, sender:Any?) {    if let identifier = segue.identifier {        switch identifier { case Segue.showDetail.rawValue: ...

Get iOS 13 Programming for Beginners - Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.