0

So I am trying to make a macOS window close after a selected period of time. I read online that I could use self.view.window?.close to make it disappear. So far, that is not working.

Do any of you have any tips?

Also, I want it to open another window after the 1st one closes. So I don't want it to quit the app entirely.

EDIT: I found out by using print(self.view.window) was set to nil. What does that mean and how do I fix it?

1 Answers1

0

this is redundant code but sometimes I have managed to solve this issue like this:

// Window reference
var window: NSWindow?  

// After window is displayed, get the handle to it
window = self.view.window!

// To dismiss it try
window?.performClose(nil) // nil or empty value

Hope it helps.

Diego Jiménez
  • 1,398
  • 1
  • 15
  • 26