I can't pass in the data from ViewController to NewVC --another UIViewController . I have been stuck here for hours with no result so this is my last resort for solving this.
For underlaying idea :
My Code For ViewController
class ViewController: UIViewController{
@IBOutlet weak var name: UITextField!
@IBOutlet weak var lastName: UITextField!
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
switch segue.identifier {
case "seg_One"? :
if let source = segue.source as? ViewController
,let destination = segue.destination as? NewVC {
destination.name.text = source.name.text //Error
destination.lastName.text = source.lastName.text //Error
}
default: break
}
}
// Bunch of other code such as ViewDidLoad()
}
NewVC code:
class NewVC: UIViewController {
@IBOutlet weak var name: UILabel!
@IBOutlet weak var lastName: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
}
}
Error is: fatal error: unexpectedly found nil while unwrapping an Optional value