NSScriptExecutionContext Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/Foundation.framework
Availability
Available in OS X v10.0 and later.
Companion guide
Declared in
NSScriptExecutionContext.h

Overview

An NSScriptExecutionContext object is a shared instance (there is only one instance of the class) that represents the context in which the current script command is executed. NSScriptExecutionContext tracks global state relating to the command being executed, especially the top-level container object (that is, the container implied by a specifier object that specifies no container) used in an evaluation of an NSScriptObjectSpecifier object.

In most cases, the top-level container for a complete series of nested object specifiers is automatically set to the application object (NSApp), and you can get this object with the topLevelObject method. But you can also set this top-level container to something else (using setTopLevelObject:) if the situation warrants it.

It is unlikely that you will need to subclass NSScriptExecutionContext.

Tasks

Getting the Current Context

Getting and Setting the Container Object

Class Methods

sharedScriptExecutionContext

Returns the shared NSScriptExecutionContext instance.

+ (NSScriptExecutionContext *)sharedScriptExecutionContext
Return Value

The shared NSScriptExecutionContext instance, creating it first if it doesn’t exist.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSScriptExecutionContext.h

Instance Methods

objectBeingTested

Returns the top-level container object currently being tested in a “whose” qualifier.

- (id)objectBeingTested
Return Value

The top-level container object currently being tested in a “whose” qualifier. Returns nil if such an object does not exist.

Availability
  • Available in OS X v10.0 and later.
See Also
Declared In
NSScriptExecutionContext.h

rangeContainerObject

Returns the top-level container object for an object specifier (encapsulated in an NSRangeSpecifier object) that represents the first or last element in a range of elements.

- (id)rangeContainerObject
Return Value

The top-level container object for an object specifier (encapsulated in an NSRangeSpecifier object) that represents the first or last element in a range of elements.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSScriptExecutionContext.h

setObjectBeingTested:

Sets the top-level container object currently being tested in a “whose” qualifier to a given object.

- (void)setObjectBeingTested:(id)object
Parameters
object

The top-level container object currently being tested.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSScriptExecutionContext.h

setRangeContainerObject:

Sets the top-level container object for a range-specifier evaluation to a give object.

- (void)setRangeContainerObject:(id)container
Parameters
container

The top-level container object for a range-specifier evaluation.

Discussion

Instances of NSRangeSpecifier contain object specifiers representing the first or last element in a range of elements, and these specifiers are evaluated in the context of container.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSScriptExecutionContext.h

setTopLevelObject:

Sets the top-level object for an object-specifier evaluation.

- (void)setTopLevelObject:(id)anObject
Parameters
anObject

The top-level object for an object-specifier evaluation.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSScriptExecutionContext.h

topLevelObject

Returns the top-level object for an object-specifier evaluation.

- (id)topLevelObject
Return Value

The top-level object for an object-specifier evaluation.

Discussion

For applications, this object is automatically set to the application object, but can be set to some other container object.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSScriptExecutionContext.h