- Inherits from:
- NSObject
- Package:
- com.apple.yellow.foundation
NSTimer creates timer objects, or more simply, timers. A timer waits until a certain time interval has elapsed and then fires, sending a specified message to a specified object. For example, you could create an NSTimer that sends a message to a window, telling it to update itself after a certain time interval.
Timers work in conjunction with NSRunLoop objects. NSRunLoops control loops that wait for input, and they use timers to help determine the maximum amount of time they should wait. When the timer's time limit has elapsed, the NSRunLoop fires the timer (causing its message to be sent), then checks for new input. Because of the various input sources a typical run loop manages, the effective resolution of the time interval for an NSTimer is limited to on the order of 50-100 milliseconds.
If you specify that the timer should repeat, it will automatically reschedule itself after it fires.
There is no method that removes the association of a timer from an NSRunLoop-send the timer the invalidate message instead. invalidate disables the timer, so it will no longer affect the NSRunLoop.
See the NSRunLoop class description for more information on NSRunLoops.
- Constructors
- NSTimer
- Stopping a timer
- invalidate
- Getting information about a timer
- isValid
- timeInterval
- userInfo
public NSTimer()
public NSTimer(
double aDouble,
Object anObject,
NSSelector aSelector,
Object anObject,
boolean aBoolean)
public void invalidate()
public boolean isValid()
public double timeInterval()
public Object userInfo()