Im getting this error:
fatal error: unexpectedly found nil while unwrapping an Optional
...when i try to change a labels Text in the Interface controller, calling the function from the notification controller, when receiving a notification. Thats my code:
InterfaceController.swift
func test() {
patt.setText("testtesttest")
}
NotificationController.swift
let controller = InterfaceController()
override func didReceiveRemoteNotification(remoteNotification: [NSObject : AnyObject], withCompletion completionHandler: ((WKUserNotificationInterfaceType) -> Void)) {
controller.test()
completionHandler(.Custom)
}
The error disappears when i remove the function and print works fine so why doesn't setText work? How can it be nil when i set it to "testtesttest"?
EDIT: The error is thrown by: setText("testtesttest")
Thanks in advance!