Instance Method


Stops a modal event loop.


- (void)stopModal;


This method should always be paired with a previous invocation of runModalForWindow: or beginModalSessionForWindow:. When runModalForWindow: is stopped with this method, it returns NSModalResponseStop. In macOS 10.9 and later, you can use this method to stop a runModalForWindow: loop outside of an event callback, such as from within a method repeatedly invoked by an NSTimer object or a method running in a different thread.

See Also

Running a Modal Window

- runModalForWindow:

Starts a modal event loop for the specified window.

- stopModalWithCode:

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

- abortModal

Aborts the event loop started by runModalForWindow: or runModalSession:.

- beginModalSessionForWindow:

Sets up a modal session with the given window and returns a pointer to the NSModalSession structure representing the session.

- runModalSession:

Runs a given modal session, as defined in a previous invocation of beginModalSessionForWindow:.


The modal window displayed by the app.


A set of button return values for modal dialogs.


Variables of type NSModalSession point to information used by the system between NSApplication’s beginModalSessionForWindow: and endModalSession: messages.


A run loop should be set to this mode when waiting for input from a modal panel, such as NSSavePanel or NSOpenPanel.