stop(_:)
Stops the main event loop.
Declaration
func stop(_ sender: Any?)Parameters
- sender:
The object that sent this message.
Discussion
This method notifies the app that you want to exit the current run loop as soon as it finishes processing the current NSEvent object. This method doesn’t forcibly exit the current run loop. Instead it sets a flag that the app checks only after it finishes dispatching an actual event object. For example, you could call this method from an action method responding to a button click or from one of the many methods defined by the NSResponder class. However, calling this method from a timer or run-loop observer routine wouldn’t stop the run loop because they don’t result in the posting of an NSEvent object.
If you call this method from an event handler running in your main run loop, the app object exits out of the run() method, thereby returning control to the main() function. If you call this method from within a modal event loop, it will exit the modal loop instead of the main event loop.