I am trying to display a custom popup menu using a UIViewController. I have written a function to enable the re-use of displaying the popup. However, I keep getting the error above and I do not know how to handle the "nil".
SWIFT:
func showPopUp(msg: String){
let storyboard = UIStoryboard.init(name: "Main", bundle: nil)
let popUpVC = storyboard.instantiateViewController(withIdentifier: "popupEmpty") as! PopUpViewController
popUpVC.messageLabel.text = msg // ""Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value" - SWIFT"
self.present(popUpVC, animated: true, completion: nil)
}
My msg parameter is not an optioanl type. I am somewhat confused.