Input Modes

Run loops can be run in different modes. A mode, which is identified by an arbitrary string, defines a collection of input sources that is monitored while the run loop is in that mode. For example, you can have one mode that runs while the application is idle, waiting for all types of events to process, and another that only listens to a particular port, waiting for a response from a distributed object request. You do not want to handle keyboard events in the latter case, since the application has not finished processing an earlier event which caused the distributed object request to be made.

NSRunLoop defines this input mode:

Input mode



Use this mode to deal with input sources other than NSConnections. This is the most commonly used run loop mode.

In addition, NSConnection defines this mode:

Input mode



Use this mode to indicate NSConnection objects waiting for replies. You rarely need to use this mode.

And NSApplication defines these modes:

Input mode



Use this mode when waiting for input from a modal panel, such as NSSavePanel or NSOpenPanel.


Use this mode for event tracking loops.

You associate a list of input sources with each input mode. Sources are added with either the NSRunLoop methods addPort:forMode: or addTimer:forMode: or one of the convenience methods provided by NSConnection, NSPort, and NSTimer. Input sources can be added to multiple input modes.

You create additional modes by specifying a new mode name when adding an input source to that mode.