stopModal(withCode:)
Stops a modal event loop, allowing you to return a custom result code.
Declaration
func stopModal(withCode returnCode: NSApplication.ModalResponse)Parameters
- returnCode:
The result code you want returned from the Runmodal(for:) or Runmodalsession(_:) method. The meaning of this result code is up to you.
Discussion
This method should always be paired with a previous invocation of runModal(for:) or beginModalSession(for:). When runModal(for:) is stopped with this method, it returns the given returnCode. In macOS 10.9 and later, you can use this method to stop a runModal(for:) loop outside of an event callback, such as from within a method repeatedly invoked by an Timer object or a method running in a different thread.