Class

NSRunLoop

The programmatic interface to objects that manage input sources.

Overview

A NSRunLoop object processes input for sources such as mouse and keyboard events from the window system, NSPort objects, and NSConnection objects. A NSRunLoop object also processes NSTimer events.

Your application neither creates or explicitly manages NSRunLoop objects. Each NSThread object—including the application’s main thread—has an NSRunLoop object automatically created for it as needed. If you need to access the current thread’s run loop, you do so with the class method currentRunLoop.

Note that from the perspective of NSRunLoop, NSTimer objects are not "input"—they are a special type, and one of the things that means is that they do not cause the run loop to return when they fire.

Topics

Accessing Run Loops and Modes

currentRunLoop

Returns the run loop for the current thread.

currentMode

The receiver's current input mode.

limitDateForMode:

Performs one pass through the run loop in the specified mode and returns the date at which the next timer is scheduled to fire.

mainRunLoop

Returns the run loop of the main thread.

getCFRunLoop

Returns the receiver's underlying CFRunLoop object.

Managing Timers

addTimer:forMode:

Registers a given timer with a given input mode.

Managing Ports

addPort:forMode:

Adds a port as an input source to the specified mode of the run loop.

removePort:forMode:

Removes a port from the specified input mode of the run loop.

Configuring as Server Process

configureAsServer

Deprecated. Does nothing.

Deprecated

Running a Loop

run

Puts the receiver into a permanent loop, during which time it processes data from all attached input sources.

runMode:beforeDate:

Runs the loop once, blocking for input in the specified mode until a given date.

runUntilDate:

Runs the loop until the specified date, during which time it processes data from all attached input sources.

acceptInputForMode:beforeDate:

Runs the loop once or until the specified date, accepting input only for the specified mode.

Scheduling and Canceling Messages

performSelector:target:argument:order:modes:

Schedules the sending of a message on the receiver.

cancelPerformSelector:target:argument:

Cancels the sending of a previously scheduled message.

cancelPerformSelectorsWithTarget:

Cancels all outstanding ordered performs scheduled with a given target.

Constants

Run Loop Modes

NSRunLoop defines the following run loop mode.

Relationships

Inherits From

See Also

Run Loop Scheduling

NSTimer

A timer that fires after a certain time interval has elapsed, sending a specified message to a target object.