picofuse-objc

Instance Methods | Class Methods | List of all members
NXNetworkTime Class Reference

The time from an NTP server, by its name or address, as an event source of the application, which sends a target an NXNetworkEventTime with each time it gets. More...

#import <Network/Network.h>

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

Instance Methods

(NXString *) - host
 Returns its server's name or address, or nil for the default.
 
(NXDuration) - interval
 Returns how often it asks, once it's had a reply.
 
(BOOL) - setTarget:selector:
 Sets what's sent each time it gets, or nil for none, and returns NO, changing nothing, if the selector isn't a method of the target which takes one object.
 
(BOOL) - isAttached
 Returns YES if it's attached, and so asks its server.
 
- Instance Methods inherited from NXObject
(void) - dealloc
 Frees the instance. More...
 
(NXZone *) - zone
 Returns the zone in which the instance was allocated. More...
 
(id) - retain
 Increases the retain count of the receiver. More...
 
(void) - release
 Decreases the retain count of the receiver. More...
 
(id) - autorelease
 Releases the receiver later, when the current autorelease pool of the thread is drained. More...
 
(id) - copy
 Returns a copy which can't be changed by anything else, which the caller owns and has to release. More...
 
(uintptr_t) - hash
 Returns a number for the object, which is the same for objects which are equal by isEqual:. More...
 
(NXString *) - description
 Returns a string which describes the instance, for logging. More...
 
- Instance Methods inherited from Object
(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...
 
- Instance Methods inherited from <ObjectProtocol>
(BOOL) - respondsToSelector:
 Checks if the receiver responds to a selector. More...
 

Class Methods

(NXNetworkTime *) + defaultTime
 Returns the time from time.cloudflare.com's address, asked each hour. More...
 
(NXNetworkTime *) + timeWithHost:interval:
 Returns the time from a server, by its name, such as "pool.ntp.org", or its address, asked at an interval. More...
 
- Class Methods inherited from NXObject
(id) + alloc
 Allocates a new instance in the default zone, or if there isn't one, with sys_calloc(). More...
 
(id) + allocWithZone:
 Allocates a new instance in a specific zone. More...
 
(id) + new
 Allocates and initializes a new instance, as [[cls alloc] init] does. More...
 
(NXString *) + description
 Returns the name of the class.
 
- Class Methods inherited from Object
(void) + initialize
 Performs one-time initialization for the class. 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...
 

Additional Inherited Members

- Protected Attributes inherited from Object
Class isa
 A pointer to the object's class structure. More...
 

Detailed Description

The time from an NTP server, by its name or address, as an event source of the application, which sends a target an NXNetworkEventTime with each time it gets.

While it's attached, it asks the server as it's attached, and then at its interval, or after 10 seconds when it gets no reply, as when there's no network yet; it never waits, so the run loop doesn't. A server's name is looked up each time it asks, usually from the DNS resolver's cache, so a pool's servers change. The time is UTC, and it doesn't set the clock. There's one at a time.

NXNetworkTime *time = [NXNetworkTime timeWithHost:@"pool.ntp.org" interval:NXHour];
[time setTarget:self selector:@selector(time:)];
- (void)time:(NXNetworkEvent *)event {
NXLog(@"It's %@", [event date]);
}

The message is sent on any of the run loop's workers, while it's attached: once -[NXApplication detachEventSource:] returns, none is being sent, unless it was called from one.

Definition at line 37 of file NXNetworkTime.h.

Method Documentation

◆ defaultTime()

+ (NXNetworkTime *) defaultTime

Returns the time from time.cloudflare.com's address, asked each hour.

Returns
It, or nil if there's one already.

◆ timeWithHost:interval:()

+ (NXNetworkTime *) timeWithHost: (NXString *)  host
interval: (NXDuration)  interval 

Returns the time from a server, by its name, such as "pool.ntp.org", or its address, asked at an interval.

Parameters
hostIts name or address, or nil for time.cloudflare.com's address.
intervalHow often it asks, once it's had a reply, rounded up to a millisecond, or 0 for an hour.
Returns
It, or nil if there's one already, the interval's negative, or the name won't do.

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