Class: NSProcessInfo

Inherits:
NSObject show all

Overview

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.

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from NSObject

#!, #!=, #!~, #, #==, #===, #=~, #Rational, #__callee__, #__method__, #__send__, #__type__, `, alloc, allocWithZone:, #autoContentAccessingProxy, autoload, autoload?, autorelease_pool, #awakeAfterUsingCoder:, binding, block_given?, caller, cancelPreviousPerformRequestsWithTarget:, cancelPreviousPerformRequestsWithTarget:selector:object:, catch, class, classFallbacksForKeyedArchiver, #classForCoder, #classForKeyedArchiver, classForKeyedUnarchiver, #clone, conformsToProtocol:, #copy, copyWithZone:, #dealloc, #define_singleton_method, description, display, #doesNotRecognizeSelector:, #dup, #enum_for, #eql?, #equal?, #extend, fail, #finalize, format, #forwardInvocation:, #forwardingTargetForSelector:, framework, #freeze, #frozen?, getpass, gets, global_variables, #init, initialize, #initialize_clone, #initialize_copy, #initialize_dup, #inspect, instanceMethodForSelector:, instanceMethodSignatureForSelector:, #instance_eval, #instance_exec, #instance_of?, #instance_variable_defined?, #instance_variable_get, #instance_variable_set, #instance_variables, instancesRespondToSelector:, isSubclassOfClass:, #is_a?, iterator?, #kind_of?, lambda, load, load_bridge_support_file, load_plist, local_variables, loop, #method, #methodForSelector:, #methodSignatureForSelector:, #methods, #mutableCopy, mutableCopyWithZone:, new, #nil?, open, p, #performSelector:onThread:withObject:waitUntilDone:, #performSelector:onThread:withObject:waitUntilDone:modes:, #performSelector:withObject:afterDelay:, #performSelector:withObject:afterDelay:inModes:, #performSelectorInBackground:withObject:, #performSelectorOnMainThread:withObject:waitUntilDone:, #performSelectorOnMainThread:withObject:waitUntilDone:modes:, print, printf, #private_methods, proc, #protected_methods, #public_method, #public_methods, #public_send, putc, puts, raise, rand, readline, readlines, #replacementObjectForCoder:, #replacementObjectForKeyedArchiver:, require, resolveClassMethod:, resolveInstanceMethod:, #respond_to?, #respond_to_missing?, select, #send, setVersion:, #singleton_methods, sprintf, srand, superclass, #taint, #tainted?, #tap, test, throw, #to_plist, #to_s, trace_var, trap, #trust, #untaint, untrace_var, #untrust, #untrusted?, version

Constructor Details

This class inherits a constructor from NSObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class NSObject

Class Method Details

+ (NSProcessInfo) processInfo

Returns the 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.

Returns:

  • (NSProcessInfo)

    Shared process information agent for the process.

Instance Method Details

- (Integer) activeProcessorCount

Provides the number of active processing cores available on the computer.

Returns:

  • (Integer)

    Number of active processing cores.

- (Array) arguments

Returns the command-line arguments for the process.

Returns:

  • (Array)

    Array of strings with the process’s command-line arguments.

- (Hash) environment

Returns the variable names and their values in the environment from which the process was launched.

Returns:

  • (Hash)

    Dictionary of environment-variable names (keys) and their values.

- (String) globallyUniqueString

Returns a global unique identifier for the process. 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.

Returns:

  • (String)

    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.

- (String) hostName

Returns the name of the host computer.

Returns:

  • (String)

    Host name of the computer.

- (Integer) operatingSystem

Returns a constant to indicate the operating system on which the process is executing.

Returns:

  • (Integer)

    Operating system identifier. See “Constants” for a list of possible values. In OS X, it’s NSMACHOperatingSystem.

- (String) operatingSystemName

Returns a string containing the name of the operating system on which the process is executing.

Returns:

  • (String)

    Operating system name. In OS X, it’s @“NSMACHOperatingSystem”

- (String) operatingSystemVersionString

Returns a string containing the version of the operating system on which the process is executing.

Returns:

  • (String)

    Operating system version. This string is human readable, localized, and is appropriate for displaying to the user. This string is not appropriate for parsing.

- (Integer) physicalMemory

Provides the amount of physical memory on the computer.

Returns:

  • (Integer)

    Amount of physical memory in bytes.

- (Integer) processIdentifier

Returns the identifier of the process.

Returns:

  • (Integer)

    Process ID of the process.

- (String) processName

Returns the 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.

Returns:

  • (String)

    Name of the process.

- (Integer) processorCount

Provides the number of processing cores available on the computer.

Returns:

  • (Integer)

    Number of processing cores.

- (Object) setProcessName(name)

Sets the name of 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.

Parameters:

  • name (String)

    New name for the process.

Returns:

- (NSTimeInterval) systemUptime

Returns how long it has been since the computer has been restarted.

Returns:

  • (NSTimeInterval)

    An NSTimeInterval indicating how long since the computer has been restarted.