I'm trying to show one of my ViewControllers
of a different storyboard programmatically. But for some reasons the properties of the ViewController
I'm trying to show are nil.
That's my error: Unexpectedly found nil while unwrapping an Optional value
I'm getting the error in my
SecondViewController
. It is showing but my app crashes due to the properties being nil.
That's my code:
let secondStoryBoard = UIStoryboard(name: "SecondStoryBoard", bundle: nil)
let secondViewController = secondStoryBoard.instantiateViewController(withIdentifier: "secondVC") as! SecondVC
self.navigationController?.pushViewController(secondViewController, animated: true)
That's the code producing the error:
class SecondVC: ViewController
{
@IBOutlet weak var mapView: MKMapView!
mapView.isHidden = true // ERROR!! Unexpectedly found nil while unwrapping an Optional value
}
SOLVED: just had to reconnect my
@IBOutlet
connections