Return to the Alphabetic Index
Return to the Class Browser
Return to the Picture Browser
Copyright (c) 1994 by NeXT Computer, Inc. All Rights
Reserved.
NSRunLoop
Inherits From: NSObject
Conforms To: NSObject (NSObject)
Declared In: Foundation/NSRunLoop.h
Class Description
The NSRunLoop class declares the programmatic interface to objects that manage
input sources. An NSRunLoop object processes input for sources such as mouse
and keyboard events from the window system, NSTimers, POSIX file descriptors,
and NSConnections, based on a mode argument. A given NSRunLoop object
processes input for input sources associated with a particular mode.
In general, your application won't need to either create or explicitly manage
NSRunLoop objects. Each thread has an NSRunLoop object automatically created
for it. The NSApplication object creates a default thread and therefore creates
a default run loop.
Applications wanting to perform their own explicit run loop management should
send the currentRunLoop message to the NSRunLoop class object to obtain
the NSRunLoop object for the current thread, then invoke one of the methods
described below in Running a Run Loop to obtain
input.
Currently defined modes are:
NSDefaultRunLoopMode Use this mode to deal with input sources other than
NSConnections. Defined in the Foundation/NSRunLoop.h header file.
NSConnectionReplyMode Use this mode to indicate NSConnections waiting for
replies. Defined in the Foundation/NSConnection.h header file.
Accessing the Current Run Loop
- + (NSRunLoop *)currentRunLoop Returns the NSRunLoop for the current
thread.
- - (NSString *)currentMode Returns the current run loop mode.
- - (NSDate *)limitDateForMode:(NSString *)mode Polls timers and
platform-specific input managers for their limit date (if any). Timers will
fire if appropriate. Returns nil if there are no input sources for this
mode.
Adding Timers
- - (void)addTimer:(NSTimer *)aTimer Registers the timer
aTimer with input filter mode. The run
forMode:(NSString *)mode loop causes the timer to fire at its
scheduled fire date. Note that timers are removed from modes if they supply
nil as their fire date.
Running a Run Loop
- - (void)acceptInputForMode:(NSString *)mode Runs the run loop,
accepting input from the input sources
beforeDate:(NSDate *)limitDate for the mode specified by
mode until the time specified by limitDate.
- - (void)run Runs the run loop in the default mode until there is nothing
to do.
- - (BOOL)runMode:(NSString *)mode Runs the run loop, accepting
input from filter mode
beforeDate:(NSDate *)limitDate until limitDate or
until the earliest limit date for input sources in this mode. Returns NO
without starting the run loop if there are no limit dates set for input sources
(that is, there's nothing to do).
- - (void)runUntilDate:(NSDate *)limitDate Runs the run loop
until limitDate or until there are no limit dates set for
input sources (that is, there's nothing to do).