Earlier in this book, we added an unwind for our Cancel button. Now, we need to make it so that our Done button can also dismiss the modal, but we also want to capture the selected location when the user is done. Let's add this code next:
- Open the ExploreViewController.swift file again and, in the private extension under the unwindLocationCancel() function, add the following code:
@IBAction func unwindLocationDone(segue:UIStoryboardSegue) { if let viewController = segue.source as? LocationViewController { selectedCity = viewController.selectedCity if let location = selectedCity { headerView.lblLocation.text = location.full } }}
The code we just added checks the source of the segue. If its source is a class of ...