Foodtracker tutorial - can't ctrl-drag - solution?

Hi everyone,


I'm working my way through the Apple Swift tutorial "FoodTracker" and everything works except the save data-part.


I think it's related to the unwindsegue that Apple wants me to use and XCode refuses to let me use.

(https://developer.apple.com/library/content/referencelibrary/GettingStarted/DevelopiOSAppsSwift/ImplementNavigation.html#//apple_ref/doc/uid/TP40015214-CH16-SW1)


The new meal/data is only supposed to be added when the save button is pressed and the unwindsegue sequence is used. However, this requires me to control-drag from my Save button to the Exit item, hereby linking my save button to the unwindToMealList function. And it doesn't work; nothing works. When ctrl-dragging, the Exit item isn't recognised, so I can't link to the function. From my searches, I can see I'm not the only one having this issue with XCode, but can't find a workaround.


So, my app is pretty much useless at the moment since I can only delete sample data, but not add anything new. I can press the save button all I want, but the view doesn't change as is the idea according to the tutorial.


I've thought about going without the unwindToMealList function / adapting it so the segue isn't required - + then add my own "back button" that doesn't require a segue but just goes back to my TableView and just letting Save handle the saving data-part.


Does anyone have any ideas on how to go about this?


My unwindToMealList function, in case anyone is interested - taken from the tutorial:


  1. @IBAction func unwindToMealList(sender: UIStoryboardSegue) {
  2.   if let sourceViewController = sender.source as? MealViewController, let meal = sourceViewController.meal {
  3.   
  4.   if let selectedIndexPath = tableView.indexPathForSelectedRow {
  5.   // Update an existing meal.
  6.   meals[selectedIndexPath.row] = meal
  7.   tableView.reloadRows(at: [selectedIndexPath], with: .none)
  8.   }
  9.   else {
  10.   // Add a new meal.
  11.   let newIndexPath = IndexPath(row: meals.count, section: 0)
  12.   
  13.   meals.append(meal)
  14.   tableView.insertRows(at: [newIndexPath], with: .automatic)
  15.   }
  16.   }
  17. }



Thanks!


/Steadi