Nauman Ahmad Nauman Ahmad - 6 months ago 10
Swift Question

Can't pass data to another view controller in when preparing for segue

I am trying to pass an object to another view controller but I get an error when I try to set the property of the view controller object.

error_xcode

Answer

The error is pretty informative. It says the class ViewController has no public or internal property called data. You'll have to declare a property called data in class ViewController.

class ViewController: UIViewController {

  var data: String?

}