I'm getting the following error when i try to update a label in swift.
fatal error: unexpectedly found nil while unwrapping an Optional value
There must be something I am missing. These are the two variables involved:
And this is the func
where I seem to get the error:
As far as I can see the variable that I want to update the label with has a value of 19.875531899929
and I want the label to show the Int
part of that. Where does the nil come from? I am stuck finding the bug.
Can the fact that I called the method from a ViewController instance in the applicationDidBecomeActive
method of AppDelegate.swift have anything to do with it? This is the short code to call the method:
func applicationDidBecomeActive(application: UIApplication) {
viewControllerInstance.convertAlertTimeToCountdownFromMinutes()
}
And the variable in AppDelegate.swift:
var viewControllerInstance = ViewController()