Instance Method

applicationShouldTerminate:

Sent to notify the delegate that the application is about to terminate.

Declaration

- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender;

Parameters

sender

The application object that is about to be terminated.

Return Value

One of the values defined in NSApplicationTerminateReply constants indicating whether the application should terminate. For compatibility reasons, a return value of NO is equivalent to NSTerminateCancel, and a return value of YES is equivalent to NSTerminateNow.

Discussion

This method is called after the application’s Quit menu item has been selected, or after the terminate: method has been called. Generally, you should return NSTerminateNow to allow the termination to complete, but you can cancel the termination process or delay it somewhat as needed. For example, you might delay termination to finish processing some critical data but then terminate the application as soon as you are done by calling the replyToApplicationShouldTerminate: method.

See Also

Terminating Applications

- applicationShouldTerminateAfterLastWindowClosed:

Invoked when the user closes the last window the application has open.

- applicationWillTerminate:

Sent by the default notification center immediately before the application terminates.

NSApplicationTerminateReply

Constants used by the delegate method applicationShouldTerminate: to determine whether an app should terminate.