Instance Method

stop:

Stops the main event loop.

Declaration

- (void)stop:(id)sender;

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 does not 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 would not stop the run loop because they do not 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.

See Also

Managing the Event Loop

- nextEventMatchingMask:untilDate:inMode:dequeue:

Returns the next event matching a given mask, or nil if no such event is found before a specified expiration date.

- discardEventsMatchingMask:beforeEvent:

Removes all events matching the given mask and generated before the specified event.

currentEvent

The last event object that the app retrieved from the event queue.

running

A Boolean value indicating whether the main event loop is running.

- run

Starts the main event loop.

- finishLaunching

Activates the app, opens any files specified by the NSOpen user default, and unhighlights the app’s icon.

- sendEvent:

Dispatches an event to other objects.

- postEvent:atStart:

Adds a given event to the receiver’s event queue.

NSEventTrackingRunLoopMode

A run loop should be set to this mode when tracking events modally, such as a mouse-dragging loop.