objc

Instance Methods | Class Methods | Protected Attributes
NXTimer Class Reference

The NXTimer class. More...

#import <Application/Application.h>

Inheritance diagram for NXTimer:
Inheritance graph
[legend]
Collaboration diagram for NXTimer:
Collaboration graph
[legend]

Instance Methods

(id< TimerDelegate >) - delegate
 Gets the current timer delegate. More...
 
(void) - setDelegate:
 Sets the timer delegate. More...
 
(BOOL- fire
 Manually fires the timer. More...
 
(void) - invalidate
 Invalidates and stops the timer. More...
 
(BOOL- valid
 Checks if the timer is still valid and active. More...
 
(NXTimeInterval- interval
 Gets the timer's configured time interval. More...
 
(BOOL- repeats
 Returns whether the timer is set to repeat. More...
 
- Instance Methods inherited from NXObject
(id- retain
 Increases the retain count of the receiver. More...
 
(void) - release
 Decreases the retain count of the receiver. More...
 
(id- autorelease
 Adds the receiver to the autorelease pool.
 
- Instance Methods inherited from Object
(void) - dealloc
 Free resources for an existing instance.
 
(id- init
 Initialize the instance, after allocation. More...
 
(Class- class
 Returns the class of the instance. More...
 
(Class- superclass
 Returns the superclass of the instance. More...
 
(BOOL- isEqual:
 Compares the receiver to another object for equality. More...
 
(BOOL- isKindOfClass:
 Returns a Boolean value that indicates whether the receiver is an instance of a given class. More...
 
(BOOL- conformsTo:
 Checks if the receiver's class conforms to a protocol. More...
 
(NXString *) - description
 Returns a string that represents the instance. More...
 
- Instance Methods inherited from <ObjectProtocol>
(BOOL- respondsToSelector:
 Checks if the receiver responds to a selector. More...
 

Class Methods

(NXTimer *) + timerWithInterval:repeats:
 Creates a new timer with the specified time interval and repeat behaviour. More...
 
- Class Methods inherited from NXObject
(id+ allocWithZone:
 Allocates a new instance of an object in a specific memory zone. More...
 
- Class Methods inherited from Object
(void) + initialize
 Performs one-time initialization for the class. More...
 
(id+ alloc
 Allocate a new class instance. More...
 
(Class+ class
 Returns the class object. More...
 
(Class+ superclass
 Returns the superclass of the class. More...
 
(const char *) + name
 Returns the name of the class. More...
 
(BOOL+ conformsTo:
 Checks if the class conforms to a protocol. More...
 
(NXString *) + description
 Returns a string that represents the class. More...
 

Protected Attributes

sys_timer_t _timer
 Scheduled timer.
 
id< TimerDelegate_delegate
 The timer delegate.
 
BOOL _repeats
 Flag to indicate if the timer should be canceled on firing.
 
NXTimeInterval _interval
 The time interval.
 
- Protected Attributes inherited from NXObject
id _zone
 The memory zone where the object is allocated.
 
unsigned short _retain
 The retain count of the object.
 
id _next
 The next object in an autorelease pool.
 
- Protected Attributes inherited from Object
Class isa
 A pointer to the object's class structure. More...
 

Detailed Description

The NXTimer class.

NXTimer represents a class for controlling timers.

Examples:
examples/Application/blink/main.m, examples/Application/timer/main.m, and examples/Network/ntp/main.m.

Definition at line 19 of file NXTimer.h.

Method Documentation

◆ delegate()

- (id<TimerDelegate>) delegate

Gets the current timer delegate.

Returns
The current timer delegate, or nil if no delegate is set.

This method returns the object that serves as the timer's delegate.

See also
- setDelegate: for setting the timer - delegate.

◆ fire()

- (BOOL) fire

Manually fires the timer.

Returns
YES if the timer was successfully fired, NO otherwise.

This method immediately triggers the timer's firing behavior, calling the delegate's timer callback method. For repeating timers, this does not affect the regular firing schedule.

◆ interval()

- (NXTimeInterval) interval

Gets the timer's configured time interval.

Returns
The time interval in seconds between timer firings.

This returns the interval that was set when the timer was created. The interval cannot be changed after timer creation.

◆ invalidate()

- (void) invalidate

Invalidates and stops the timer.

Once a timer is invalidated, it cannot be reused and will no longer fire. This method should be called to clean up timers that are no longer needed to prevent memory leaks and unwanted timer callbacks.

◆ repeats()

- (BOOL) repeats

Returns whether the timer is set to repeat.

Returns
YES if the timer is repeating, NO if it is a one-shot timer.

◆ setDelegate:()

- (void) setDelegate: (id< TimerDelegate >)  delegate

Sets the timer delegate.

Parameters
delegateThe object to set as the timer delegate, or nil to remove the current delegate.

The delegate object will receive timer-related callbacks when the timer fires. The delegate should conform to the TimerDelegate protocol.

See also
- delegate for getting the current timer - delegate.

◆ timerWithInterval:repeats:()

+ (NXTimer *) timerWithInterval: (NXTimeInterval interval
repeats: (BOOL repeats 

Creates a new timer with the specified time interval and repeat behaviour.

Parameters
intervalThe time interval in seconds between timer firings.
repeatsYES if the timer should repeat automatically, NO for a one-shot timer.
Returns
A new NXTimer instance, or nil if the timer could not be created.

This class method creates and returns a new timer configured with the specified interval and repeat behavior. The timer is not automatically scheduled - you must set a delegate to ensure the timer is properly managed.

◆ valid()

- (BOOL) valid

Checks if the timer is still valid and active.

Returns
YES if the timer is valid and can fire, NO if it has been invalidated.

A timer becomes invalid when it has been explicitly invalidated or when a non-repeating timer has already fired.


The documentation for this class was generated from the following file: