PATH  Documentation > Mac OS X > Foundation Reference: Java



Table of Contents

NSTimer


Inherits from:
NSObject
Package:
com.apple.yellow.foundation


Class Description


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.




Method Types


Constructors
NSTimer
Stopping a timer
invalidate
Getting information about a timer
isValid
timeInterval
userInfo


Constructors



NSTimer

public NSTimer()

Description forthcoming.

public NSTimer( double aDouble, Object anObject, NSSelector aSelector, Object anObject, boolean aBoolean)

Description forthcoming.


Instance Methods



invalidate

public void invalidate()

Stops the receiver from ever firing again. This is the only way to remove a timer from an NSRunLoop.

isValid

public boolean isValid()

Returns true if the timer is currently valid, false otherwise.

timeInterval

public double timeInterval()

Returns the timer's time interval.

userInfo

public Object userInfo()

Returns the userInfo object, containing additional data the target may use when the receiver is fired.


Table of Contents