Mac OS X Reference Library Apple Developer
Search

System

Technology area
Installer
Availability
Available in Mac OS X v10.4 and later.

Overview

The System object provides access to information about the target host. This object is accessed using the system global variable.

Tasks

Properties

Accessing Object Properties

Accessing System Information

Comparing Version Numbers

Internationalizing Distributions

Logging

Running Programs

Properties

applications

Discussion

Provides methods to obtain information about running applications. See Applications.

Availability

defaults

Discussion

Dictionary representing the defaults system.

Availability

files

Discussion

Provides file-access methods. See Files.

Availability

ioregistry

Discussion

Provides access to the IOKit registry. See IORegistry.

Availability

users.desktopSessionCount

Discussion

Number of logged-in users. (Includes only those users with a Window Server connection, that is, those that appear in the Fast User Switching list.)

Availability

version

Discussion

Dictionary (associative array) with the contents of /Sytstem/Library/CoreServices/SystemVersion.plist. See sw_vers(1).

Availability

Methods

compareVersions

Provides the result of comparing two given version strings (for example, '10.3.1' and '10.4').

compareVersions( versionA, versionB)

Parameters
versionA

String with the first operand version.

versionB

String with the second operand version.

Return Value

-1 when versionA is lower than versionB, 0 when versionA is equal to versionB, and 1 when versionA is higher than versionB.

Availability
  • Available in Mac OS X v10.4 and later.

gestalt

Provides gestalt information that corresponds to the given selector.

gestalt( selector)

Parameters
selector

String specifying the selector for the data to retrieve.

Return Value

Data for the given selector.

Discussion

For example, this expression returns '1040' on Mac OS X v10.4.0:

system.gestalt('sysv').toString(16)

See Gestalt Manager Reference for detailed information.

Availability
  • Available in Mac OS X v10.4 and later.

localizedStandardString

Provides the localized standard string in the installation package for the current locale for a given key.

localizedStandardString( stringKey)

Parameters
stringKey

String that identifies the desired localized string.

Return Value

Localized string, if found in the installation package; null otherwise.

Availability
  • Available in Mac OS X v10.4 and later.

localizedStandardStringWithFormat

Provides the formatted localized string in the installation package for the current locale for a given key and a given set of additional arguments.

localizedStandardStringWithFormat( stringKey, args...)

Parameters
stringKey

String that identifies the desired localized string.

args...

Arguments that replace placeholders (%@) in the formatted localized string.

Return Value

Localized string, if found in the installation package; null otherwise.

Availability
  • Available in Mac OS X v10.4 and later.

localizedString

Provides the localized string in the installation package for the current locale for a given key.

localizedString( stringKey)

Parameters
stringKey

String that identifies the desired localized string.

Return Value

Localized string, if found in the installation package; null otherwise.

Availability
  • Available in Mac OS X v10.4 and later.

localizedStringWithFormat

Provides the formatted localized string in the installation package for the current locale for a given key and a given set of additional arguments.

localizedStringWithFormat( stringKey, args...)

Parameters
stringKey

String that identifies the desired localized string.

args...

Arguments that replace placeholders (%@) in the formatted localized string.

Return Value

Localized string, if found in the installation package; null otherwise.

Availability
  • Available in Mac OS X v10.4 and later.

log

Generates an Installer log entry with the JS: prefix.

log( logString)

Parameters
logString

Log-entry text.

Discussion

For some objects, this function may print data that is unavailable or formatted differently when accessed in JavaScript code. To ensure that only data accessible in JavaScript code is shown in the log entry, invoke this function this way:

system.log(foo + ' ')

Such invocation forces the JavaScript interpreter to evaluate the expression and pass a String object to the function.

Availability
  • Available in Mac OS X v10.4 and later.

propertiesOf

Provides an array with the properties of a given object.

propertiesOf( object)

Parameters
object

An object.

Return Value

Array with the properties of object.

Availability
  • Available in Mac OS X v10.4 and later.

run

Launches a given program in the Resources directory of the installation package.

run( programName, args...)

Parameters
programName

Name of the program to execute.

args...

Arguments passed to the program.

Return Value

After the program is executed, its exit code. If the program is not executed (see discussion), undefined.

Discussion

The allow-external-scripts attribute of the options element in the distribution definition must be 'yes' for the program to be launched. And, the Installer application asks the user’s permission before launching the program. See Distribution Definition Reference for more information.

Availability
  • Available in Mac OS X v10.4 and later.
See Also

runOnce

Launches a given program in the Resources directory of the installation package. On subsequent invocations with the same arguments, the program is not launched and the exit code of the first execution is returned.

run( programName, args...)

Parameters
programName

Name of the program to execute.

args...

Arguments passed to the program.

Return Value

After the program is executed, its exit code. If the program is not executed (see discussion), undefined.

Discussion

The allow-external-scripts attribute of the options element in the distribution definition must be 'yes' for the program to be launched. And, the Installer application asks the user’s permission before launching the program. See Distribution Definition Reference for more information.

Use this method instead of run when a program’s exit code using the same arguments is not expected to change.

Availability
  • Available in Mac OS X v10.4 and later.

sysctl

Provides the result of a sysctlbyname() call using the given selector.

sysctl( selector)

Parameters
selector

String with the hardware selector for the desired data.

Return Value

Hardware data corresponding to selector.

Discussion

See /usr/include/sys/sysctl.h for the list of hardware selectors.

Availability
  • Available in Mac OS X v10.4 and later.



Last updated: 2008-12-16

Did this document help you? Yes It's good, but... Not helpful...