Instance Method


Starts the main event loop.


- (void)run;


The loop continues until a stop: or terminate: message is received. Upon each iteration through the loop, the next available event from the window server is stored and then dispatched by sending it to NSApp using sendEvent:.

After creating the NSApplication object, the main function should load your app’s main nib file and then start the event loop by sending the NSApplication object a run message. If you create an Cocoa app project in Xcode, this main function is implemented for you.

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.


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


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

- finishLaunching

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

- stop:

Stops the main event loop.

- sendEvent:

Dispatches an event to other objects.

- postEvent:atStart:

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


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