Hadeel Hadeel - 11 months ago 59
Swift Question

Swift 3 can't pass variable from tableView to detailView

I am trying to pass the cell name to next view (detailView) but always get this error "fatal error: unexpectedly found nil while unwrapping an Optional value"
enter image description here

Answer Source

At the time that prepare(for segue... is called, your outlets have not been assigned yet. Your view must be loaded before your outlets are assigned. You can force the view to load simply by accessing it (detailView.view), but this is a bad idea. A better approach would be to assign another property on your view controller with the value you're trying to pass around, then in viewDidLoad of your detail view controller, set the properties you wish to set on your IBOutlets.