| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/Foundation.framework |
| Availability | Available in Mac OS X v10.0 and later.
|
| Companion guide | |
| Declared in | NSProcessInfo.h |
The NSProcessInfo class provides methods to access information about the current process. Each process has a single, shared NSProcessInfo object, known as process information agent.
The process information agent can return such information as the arguments, environment variables, host name, or process name. The processInfo class method returns the shared agent for the current process—that is, the process whose object sent the message. For example, the following line returns the NSProcessInfo object, which then provides the name of the current process:
NSString *processName = [[NSProcessInfo processInfo] processName]; |
The NSProcessInfo class also includes the operatingSystem method, which returns an enum constant identifying the operating system on which the process is executing.
NSProcessInfo objects attempt to interpret environment variables and command-line arguments in the user's default C string encoding if they cannot be converted to Unicode as UTF-8 strings. If neither conversion works, these values are ignored by the NSProcessInfo object.
– arguments
– environment
– processIdentifier
– globallyUniqueString
– processName
– setProcessName:
Returns the process information agent for the process.
+ (NSProcessInfo *)processInfo
Shared process information agent for the process.
An NSProcessInfo object is created the first time this method is invoked, and that same object is returned on each subsequent invocation.
NSProcessInfo.hProvides the number of active processing cores available on the computer.
- (NSUInteger)activeProcessorCount
Number of active processing cores.
NSProcessInfo.hReturns the command-line arguments for the process.
- (NSArray *)arguments
Array of strings with the process’s command-line arguments.
NSProcessInfo.h
Returns the variable names and their values in the environment from which the process was launched.
- (NSDictionary *)environment
Dictionary of environment-variable names (keys) and their values.
NSProcessInfo.h
Returns a global unique identifier for the process.
- (NSString *)globallyUniqueString
Global ID for the process. The ID includes the host name, process ID, and a time stamp, which ensures that the ID is unique for the network.
This method generates a new string each time it is invoked, so it also uses a counter to guarantee that strings created from the same process are unique.
NSProcessInfo.hReturns the name of the host computer.
- (NSString *)hostName
Host name of the computer.
NSProcessInfo.h
Returns a constant to indicate the operating system on which the process is executing.
- (unsigned int)operatingSystem
Operating system identifier. See “Constants” for a list of possible values. In Mac OS X, it’s NSMACHOperatingSystem.
NSProcessInfo.h
Returns a string containing the name of the operating system on which the process is executing.
- (NSString *)operatingSystemName
Operating system name. In Mac OS X, it’s @"NSMACHOperatingSystem"
NSProcessInfo.hReturns a string containing the version of the operating system on which the process is executing.
- (NSString *)operatingSystemVersionString
Operating system version. This string is human readable, localized, and is appropriate for displaying to the user. This string is not appropriate for parsing.
NSProcessInfo.hProvides the amount of physical memory on the computer.
- (unsigned long long)physicalMemory
Amount of physical memory in bytes.
NSProcessInfo.hReturns the identifier of the process.
- (int)processIdentifier
Process ID of the process.
NSProcessInfo.hReturns the name of the process.
- (NSString *)processName
Name of the process.
The process name is used to register application defaults and is used in error messages. It does not uniquely identify the process.
NSProcessInfo.hProvides the number of processing cores available on the computer.
- (NSUInteger)processorCount
Number of processing cores.
NSProcessInfo.hSets the name of the process.
- (void)setProcessName:(NSString *)name
New name for the process.
Warning: User defaults and other aspects of the environment might depend on the process name, so be very careful if you change it. Setting the process name in this manner is not thread safe.
NSProcessInfo.hThe following constants are provided by the NSProcessInfo class as return values for operatingSystem.
enum {
NSWindowsNTOperatingSystem = 1,
NSWindows95OperatingSystem,
NSSolarisOperatingSystem,
NSHPUXOperatingSystem,
NSMACHOperatingSystem,
NSSunOSOperatingSystem,
NSOSF1OperatingSystem
};
NSHPUXOperatingSystemIndicates the HP UX operating system.
Available in Mac OS X v10.0 and later.
Declared in NSProcessInfo.h
NSMACHOperatingSystemIndicates the Mac OS X operating system.
Available in Mac OS X v10.0 and later.
Declared in NSProcessInfo.h
NSOSF1OperatingSystemIndicates the OSF/1 operating system.
Available in Mac OS X v10.0 and later.
Declared in NSProcessInfo.h
NSSolarisOperatingSystemIndicates the Solaris operating system.
Available in Mac OS X v10.0 and later.
Declared in NSProcessInfo.h
NSSunOSOperatingSystemIndicates the Sun OS operating system.
Available in Mac OS X v10.0 and later.
Declared in NSProcessInfo.h
NSWindows95OperatingSystemIndicates the Windows 95 operating system.
Available in Mac OS X v10.0 and later.
Declared in NSProcessInfo.h
NSWindowsNTOperatingSystemIndicates the Windows NT operating system.
Available in Mac OS X v10.0 and later.
Declared in NSProcessInfo.h
NSProcessInfo.h
Last updated: 2007-03-26