Passing location and cuisine to the restaurant list

Open the ExploreViewController.swift file, and inside the private extension, add the following method above the unwindLocationCancel() method:

func showLocationList(segue:UIStoryboardSegue) {   guard let navController = segue.destination as? UINavigationController,   let viewController = navController.topViewController as? LocationViewController else {       return    }       guard let city = selectedCity else { return }   viewController.selectedCity = city} 

Our showLocationList() method will be called whenever our destination view has a Navigation Controller. Then, it checks to see if the topViewController is of the LocationViewController class. If either of these two statements are false, we do nothing. ...

Get iOS 12 Programming for Beginners - Third 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.