Make a Cocoa application quit when the main window is closed?

后端 未结 5 1011
日久生厌
日久生厌 2021-02-05 05:18

How to make a Cocoa application quit when the main window is closed? Without that you have to click on the app icon and click quit in the menu.

5条回答
  •  情话喂你
    2021-02-05 05:47

    Add this code snippet to your app's delegate:

    -(BOOL) applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)app {
        return YES;
    }
    

提交回复
热议问题