O'Reilly logo

Cocoa in a Nutshell by James Duncan Davidson, Michael Beam

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

NSHost — Mac OS X 10.0

Synopsis

This class is used to perform host name lookup and IP address translation. Translations are provided by any services available to the operating system such as NetInfo, LDAP, or DNS. Instances of NSHost are created using one of three class methods: currentHost, hostWithAddress:, and hostWithName:. The first, currentHost, returns an NSHost object that contains information about the host running the application process. The methods hostWithName: and hostWithAddress: create NSHost objects for the host with the specified name or address. The name used in hostWithName: can be a simple host name, or it can be a fully qualified domain name. When creating a host object with hostWithAddress:, the IP address is specified as a string in dotted decimal format, such as 192.168.254.198. Once an instance of NSHost has been created, it can be queried for the IP addresses and names that the host identifies with.

image with no caption

@interface NSHost : NSObject
                                  // Convenience Constructors
   + (NSHost *)hostWithAddress:(NSString *)address;
   + (NSHost *)hostWithName:(NSString *)name;
                                  // Class Methods
   + (NSHost *)currentHost;
   + (void)flushHostCache;
   + (BOOL)isHostCacheEnabled;
   + (void)setHostCacheEnabled:(BOOL)flag;
                                  // Instance Methods
   - (NSString *)address;
   - (NSArray *)addresses;
   - (BOOL)isEqualToHost:(NSHost *)aHost;
   - (NSString *)name;
   - (NSArray *)names ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required