Xcode 9.2, macOS 10.12.6, Swift 4. I don't really know what I'm doing, so please explain what to do in detail.
I am trying to make it so that the first window is closed when the second one is opened. The buttonCONTINUE
makes the second window open, via show segue.
I followed the Control+Click and drag as explained here, and tried to make the CONTINUE button close the first window when closed in two different ways; with
self.view.window?.close()
and with setting the key equivalent to CMD
+W
.
I've tried the solution suggested here, but that did not solve my problem.
Edit:
I have two windows, one each goes to the other one. Here is the code:
override func prepare(for segue: NSStoryboardSegue, sender: Any?) {
super.prepare(for: segue, sender: sender)
if segue.identifier!.rawValue == "SegueToWIR" {
view.window?.close()
}
//neither if or else if make this work
if segue.identifier!.rawValue == "SegueToWarning" {
view.window?.close()
}
}
The second if statement doesn't cause an error, but doesn't do anything.