Stop async operations on window close

78 views Asked by At

In my app delegate I have put the callback to stop the program when the window is shut.

 func applicationShouldTerminateAfterLastWindowClosed(sender: NSApplication) -> Bool {
        return true
    }

This doesn't work however because (I assume) there is an async bluetooth task running. What is the best way to stop everything running and clean up?

1

There are 1 answers

0
Daniyar On BEST ANSWER

I use this approach

[NSApp performSelector:@selector(terminate:) withObject:nil afterDelay:0];