title: Passing data when dismissing Viewcontroller
body: <p>I want to pass data to the root view controller, which is <code>ViewController</code> after the previous one is dismissed, I chose to use delegation to solve this problem in this way: 
  Scheme: </p>
  
  <p>ViewController -> SearchViewController</p>
  
  <p><code>SearchViewController</code> produces data and dismisses</p>
  
  <pre><code>class ViewController: UIViewController, IsAbleToReceiveData {    
  @IBAction func addButton_touchUpInside(_ sender: UIButton) {
          performSegue(withIdentifier: "gotoSearchViewController", sender: nil)
      }
  
  override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
      if segue.identifier == "gotoSearchViewController" {
          let vc2 = SearchViewController()
          vc2.delegate = self
      }
  }
  
  
  func passData(city: cityObject) {
          print(city.cityName)
  
      }
  }
  </code></pre>
  
  <p>The protocol is declared: </p>
  
  <pre><code>protocol IsAbleToReceiveData: class {
     func passData(city : cityObject)
  }
  </code></pre>
  
  <p>In the <code>SearchViewController</code> I have: </p>
  
  <pre><code>weak var delegate: IsAbleToReceiveData?
  
  func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
      let citySelected: cities?
      citySelected = self.citiesQueried[indexPath.row]
      RequestAPI.convertData(city: citySelected!) { (city) in
  
          self.delegate?.passData(city: city)
      }
      dismiss(animated: true, completion: nil)
  }
  </code></pre>
  
  <p>When I try to print the data in the function in <code>ViewController</code> nothing is printed even though in <code>SearchViewController</code> <em>convertData</em> method is returning a cityObject.
  How can I pass the data to <code>ViewController</code> after dismissing? </p>