title: Calling method in another view controller from modal view controller using a delegate
body: <p>I am using a modal segue to create a view controller that I want to dismiss and then call a method in the origin view controller. I have used a protocol/delegate pattern but for some reason the method is never called. The code is below: Please note that I removed a lot of non-relevant code to keep it clean here</p>
  
  <p>Thanks!!</p>
  
  <p>VC1:</p>
  
  <pre><code>final class WorkoutViewController: UIViewController, StartWorkoutButtonDelegate {
  
  weak var dataSource: WorkoutViewControllerDataSource!
  private var workout: Workout!
  private var workoutDataViewController: WorkoutDataViewController?
  private var workoutFinishViewController: WorkoutFinishViewController?
  private let workoutFinishViewControllerSegueIdentifier = "Workout Finish View Controller Segue"
  
  @IBOutlet private var primaryActionButton: UIButton!
  @IBOutlet private var pageControl: UIPageControl!
  
  // MARK: - Handling View Lifecycle
  
  override func viewDidLoad() {
      super .viewDidLoad()
      let workoutType = dataSource.workoutType(for: self)
      workout = Workout(workoutType: workoutType, managedObjectContext: persistentContainer.viewContext)
      setPrimaryActionButtonLabel()
  }
  
  // MARK: - Handling Storyboard Segues
  
  override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
      super.prepare(for: segue, sender: sender)
  
      if let destinationWorkoutFinishViewController = segue.destination as? WorkoutFinishViewController {
          workoutFinishViewController = destinationWorkoutFinishViewController
      }
  }
  
  // MARK: - Managing Start and Pause 
  
  @IBAction func startOrPauseWorkout() {
      if workout.isPaused {
          startWorkout()
      } else {
          pauseWorkout()
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>VC 2:</p>
  
  <pre><code>protocol StartWorkoutButtonDelegate: AnyObject {
  func startOrPauseWorkout()
   }
  
  class WorkoutFinishViewController: UIViewController {
  
  weak var delegate: StartWorkoutButtonDelegate?
  
  @IBAction func startWorkout() {
      self.delegate?.startOrPauseWorkout()
      self.dismiss(animated: true, completion: nil)
  }
  
  @IBAction func finishWorkout() {
  }
  
  override func viewDidLoad() {
      super.viewDidLoad()
  
  }
  }
  </code></pre>