Contents

stopModal(withCode:)

Stops a modal event loop, allowing you to return a custom result code.

Declaration

func stopModal(withCode returnCode: NSApplication.ModalResponse)

Parameters

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.

See Also

Running a Modal Window