Hello:
I have this code and getting error:
Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value
What can I do to prevent the error? Here is the code:
class ViewController: NSViewController,NSWindowDelegate {
var window: NSWindow!
override func viewDidLoad() {
super.viewDidLoad()
}
func windowShouldClose(sender: AnyObject) -> Bool {
NSApp.hide(nil)
return false
}
override func awakeFromNib() {
super.awakeFromNib()
view.window!.delegate! = self //Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value
}
Thanks for help.