When converting String to Int type and print that Int type in console then show an error
Unexpectedly found nil while unwraping an optional value
ViewController.swift
@IBAction func btnVerifyOTP(_ sender: Any)
{
let verifyOTP =
self.storyboard?.instantiateViewController(withIdentifier: "VerifyOTP") as! VerifyOTP
self.navigationController?.pushViewController(verifyOTP, animated: true)
verifyOTP.strPhone = self.tfMobile.text!
}
ViewController2.swift
class VerifyOTP: UIViewController {
var strPhone = String()
override func viewDidLoad() {
super.viewDidLoad()
let numPhone = Int(strPhone)!
print(numPhone)
}
}
Error : This method will print "Unexpectedly found nil while unwrapping an optional value"