Handle close event of the window in Swift
How to handle close event of the window using swift, for example, to ask "Are you sure you want to close the form?" The form will be closed in the case "yes" and not closed in the case "no". Showing message box is not a problem for me. viewWillDisappear() works for minimizing also, but I need only close event. Thanks. Thomas Alvarez Like said above, you should make the ViewController an NSWindowDelegate , but you should handle windowWillClose , not windowShouldClose . windowShouldClose is to determine if the window is able to close or not, not an event that the window is actually closing. I