Return to the Alphabetic Index
Return to the Class Browser
Return to the Picture Browser
Copyright (c) 1994 by NeXT Computer, Inc. All Rights
Inherits From: NSObject
Conforms To: NSObject (NSObject)
Declared In: Foundation/NSProcessinfo.h
The NSProcessInfo class provides methods to access process-wide information. An
NSProcessInfo object can return such information as the arguments, environment,
host name, or process name. The processInfo class method returns an
NSProcessInfo object. For example, the following code creates an NSProcessInfo
object, which then provides the name of the current process:
[[NSProcessInfo processInfo] processName];
Getting an NSProcessInfo Object
Returning Process Information
- + (NSProcessInfo *)processInfo Returns the NSProcessInfo object for the
process. It is already initialized. An NSProcessInfo object is created the
first time this method is invoked, and that same object is returned on each
Specifying a Process Name
- - (NSArray *)arguments Returns the arguments as an array of NSStrings
from the command line.
- - (NSDictionary *)environment Returns a dictionary of variables defined
for the environment from which the process was launched.
- - (NSString *)hostName Returns the name of the host system.
- - (NSString *)processName Returns the name of the process under which
this program's user defaults domain is created, and is the name used in error
messages. It does not uniquely identify the process.
- - (NSString *)globallyUniqueString Returns a globally unique string to
identify the process. This method uses the host name, process ID, and a
timestamp to ensure that the string returned will be globally unique.
- - (void)setProcessName:(NSString *)newName Sets the name of the
process to newName. Warning: Aspects of the environment like
userDefaults might depend on the process name, so be very careful if you change
this. Setting the process name this way is not thread-safe.