Mac Developer Library

Developer

Foundation Framework Reference NSScriptObjectSpecifier Class Reference

Options
Deployment Target:

On This Page
Language:

NSScriptObjectSpecifier

NSScriptObjectSpecifier is the abstract superclass for classes that instantiate objects called “object specifiers.” An object specifier represents an AppleScript reference form, which is a natural-language expression such as words 10 through 20 or front document or words whose color is red. More...

Conforms To


Import Statement


import Foundation @import Foundation;

Availability


Available in OS X v10.0 and later.
  • Returns a new object specifier for an Apple event descriptor.

    Declaration

    Swift

    init?(descriptor descriptor: NSAppleEventDescriptor) -> NSScriptObjectSpecifier

    Objective-C

    + (NSScriptObjectSpecifier *)objectSpecifierWithDescriptor:(NSAppleEventDescriptor *)descriptor

    Parameters

    descriptor

    An Apple event descriptor. The descriptor must have the type typeObjectSpecifier.

    Return Value

    An object specifier, or nil if an error occurs.

    Discussion

    If objectSpecifierWithDescriptor: is invoked and fails during the execution of a script command, information about the error that caused the failure is recorded in [NSScriptCommand currentCommand].

    Import Statement

    import Foundation

    Availability

    Available in OS X v10.5 and later.

  • Returns an NSScriptObjectSpecifier object initialized with the given attributes.

    Declaration

    Swift

    init(containerClassDescription classDesc: NSScriptClassDescription, containerSpecifier container: NSScriptObjectSpecifier, key property: String)

    Objective-C

    - (instancetype)initWithContainerClassDescription:(NSScriptClassDescription *)classDesc containerSpecifier:(NSScriptObjectSpecifier *)container key:(NSString *)property

    Return Value

    An NSScriptObjectSpecifier object initialized with container specifier specifier, key key, and the class description of the object specifier classDescription, derived from the value of the specifier’s key.

    Discussion

    You should never pass nil for the value of classDescription. The receiver’s child reference is set to nil.

    This is the designated initializer for NSScriptObjectSpecifier.

    Import Statement

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • Returns an NSScriptObjectSpecifier object initialized with a given container specifier and key.

    Declaration

    Swift

    convenience init(containerSpecifier container: NSScriptObjectSpecifier, key property: String)

    Objective-C

    - (instancetype)initWithContainerSpecifier:(NSScriptObjectSpecifier *)container key:(NSString *)property

    Return Value

    An NSScriptObjectSpecifier object initialized with container specifier specifier and key key.

    Discussion

    The class description of the container is set automatically.

    Import Statement

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • This primitive method must be overridden by subclasses to return a pointer to an array of indices identifying objects in the key of a given container that are identified by the receiver of the message.

    Declaration

    Swift

    func indicesOfObjectsByEvaluatingWithContainer(_ container: AnyObject, count count: UnsafeMutablePointer<Int>) -> UnsafeMutablePointer<Int>

    Objective-C

    - (NSInteger *)indicesOfObjectsByEvaluatingWithContainer:(id)container count:(NSInteger *)count

    Discussion

    This primitive method must be overridden by subclasses to return a pointer to an array of indices identifying objects in the key of the container aContainer that are identified by the receiver of the message. The method uses key-value coding to obtain values based on the receiver’s key. It returns the number of such matching objects by indirection in numRefs. It returns nil directly and –1 via numRefs if all objects in the container (or the sole object) match the value of the receiver’s key. This method is invoked by objectsByEvaluatingWithContainers:. The default implementation returns nil directly and –1 indirectly via numRefs.

    Import Statement

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • Returns the actual object represented by the nested series of object specifiers.

    Declaration

    Swift

    var objectsByEvaluatingSpecifier: AnyObject? { get }

    Objective-C

    @property(readonly, retain) id objectsByEvaluatingSpecifier

    Return Value

    The actual object represented by the nested series of object specifiers.

    Discussion

    Recursively obtains the next container in a nested series of object specifiers until it reaches the top-level container specifier (which is either an NSWhoseSpecifier or the application object), after which it begins evaluating each object specifier (objectsByEvaluatingWithContainers:) going in the opposite direction (top-level to innermost) as it unwinds from the stack. Returns the actual object represented by the nested series of object specifiers. Returns nil if a container specifier could not be evaluated or if no top-level container specifier could be found. Thus nil can be a valid value or can indicate an error; you can use evaluationErrorNumber to determine if and which error occurred and evaluationErrorSpecifier to find the container specifier responsible for the error. In the normal course of command processing, this method is invoked by an NSScriptCommand object’s evaluatedArguments and evaluatedReceivers methods, which take as message receiver the innermost object specifier.

    Import Statement

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • Returns the actual object or objects specified by the receiver as evaluated in the context of given container object.

    Declaration

    Swift

    func objectsByEvaluatingWithContainers(_ containers: AnyObject) -> AnyObject?

    Objective-C

    - (id)objectsByEvaluatingWithContainers:(id)containers

    Return Value

    The actual object or objects specified by the receiver as evaluated in the context of its container object or objects (containers).

    Discussion

    Invokes indicesOfObjectsByEvaluatingWithContainer:count: on self to get an array of pointers to indices of elements in containers that have values paired with the message receiver’s key. This method then uses key-value coding to obtain the object or objects associated with the key; it returns these objects or nil if there are no matching values in containers. If there are multiple matching values, they are returned in an NSArray; if matching values are nil, NSNull objects are substituted. If containers is an NSArray, the method recursively evaluates each element in the array and returns an NSArray with evaluated objects (including NSNulls) in their corresponding slots.

    Import Statement

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • Returns the class description of the object indicated by the receiver’s container specifier.

    Declaration

    Swift

    var containerClassDescription: NSScriptClassDescription?

    Objective-C

    @property(retain) NSScriptClassDescription *containerClassDescription

    Return Value

    The class description of the object indicated by the receiver’s container specifier.

    Import Statement

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • If the receiver’s container specifier is nil, returns a Boolean value that indicates whether the receiver’s container is the object involved in a specifier test.

    Declaration

    Swift

    var containerIsObjectBeingTested: Bool

    Objective-C

    @property BOOL containerIsObjectBeingTested

    Return Value

    YEStrue if the receiver’s container is the object involved in a specifier test, otherwise NOfalse.

    Discussion

    An example of a specifier test is whose color is blue). If the returned value is YEStrue, then the top-level object is the object being tested (that is, the specifier has no container specifier).

    Import Statement

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • If the receiver’s container specifier is nil, returns a Boolean value that indicates whether the container for the receiver contains the range of elements represented by an NSRangeSpecifier.

    Declaration

    Swift

    var containerIsRangeContainerObject: Bool

    Objective-C

    @property BOOL containerIsRangeContainerObject

    Return Value

    YEStrue if the container for the receiver contains the range of elements represented by an NSRangeSpecifier, otherwise NOfalse.

    Import Statement

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • Returns the receiver’s container specifier.

    Declaration

    Swift

    var containerSpecifier: NSScriptObjectSpecifier?

    Objective-C

    @property(retain) NSScriptObjectSpecifier *containerSpecifier

    Return Value

    The receiver’s container specifier, which is the object specifier that must be evaluated to provide a context for the evaluation of the receiver.

    Import Statement

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • Sets the class description of the receiver’s container specifier to a given specifier.

    Declaration

    Swift

    var containerClassDescription: NSScriptClassDescription?

    Objective-C

    @property(retain) NSScriptClassDescription *containerClassDescription

    Parameters

    classDescription

    The class description of the receiver’s container specifier.

    Import Statement

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • Sets whether the receiver’s container should be an object involved in a filter reference or the top-level object.

    Declaration

    Swift

    var containerIsObjectBeingTested: Bool

    Objective-C

    @property BOOL containerIsObjectBeingTested

    Discussion

    If the receiver’s container specifier is nil and flag is YEStrue, sets the receiver’s container to be an object involved in a filter reference (for example, whose color is blue). If the receiver’s container specifier is nil and flag is NOfalse, sets the receiver’s container to be the top-level object.

    If flag is YEStrue setContainerIsRangeContainerObject: should not also be invoked with an argument of YEStrue.

    Import Statement

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • Sets the container specifier of the receiver.

    Declaration

    Swift

    var containerSpecifier: NSScriptObjectSpecifier?

    Objective-C

    @property(retain) NSScriptObjectSpecifier *containerSpecifier

    Parameters

    objSpecifier

    The container specifier for the receiver.

    Import Statement

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • Sets whether the receiver’s container is to be the container for a range specifier or a top-level object.

    Declaration

    Swift

    var containerIsRangeContainerObject: Bool

    Objective-C

    @property BOOL containerIsRangeContainerObject

    Discussion

    If the receiver’s container specifier is nil and flag is YEStrue, sets the receiver’s container to be the container for a range specifier. If the receiver’s container specifier is nil and flag is NOfalse, sets the receiver’s container to be the top-level object.

    If flag is YEStrue, setContainerIsObjectBeingTested: should not also be invoked with an argument of YEStrue.

    Import Statement

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • Returns the receiver’s child reference.

    Declaration

    Swift

    unowned(unsafe) var childSpecifier: NSScriptObjectSpecifier?

    Objective-C

    @property(assign) NSScriptObjectSpecifier *childSpecifier

    Return Value

    The receiver’s child reference, that is, the object specifier evaluating to the object or objects that the receiver contains.

    Import Statement

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • Sets the receiver’s child reference.

    Declaration

    Swift

    unowned(unsafe) var childSpecifier: NSScriptObjectSpecifier?

    Objective-C

    @property(assign) NSScriptObjectSpecifier *childSpecifier

    Parameters

    child

    The receiver’s child reference.

    Discussion

    Do not invoke this method directly; it is automatically invoked by setContainerSpecifier:.

    Import Statement

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • Returns the key of the receiver.

    Declaration

    Swift

    var key: String?

    Objective-C

    @property(copy) NSString *key

    Return Value

    The key of the receiver.

    Import Statement

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • Returns the class description of the objects specified by the receiver.

    Declaration

    Swift

    var keyClassDescription: NSScriptClassDescription? { get }

    Objective-C

    @property(readonly, retain) NSScriptClassDescription *keyClassDescription

    Return Value

    The class description of the objects specified by the receiver.

    Import Statement

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • Sets the key of the receiver.

    Declaration

    Swift

    var key: String?

    Objective-C

    @property(copy) NSString *key

    Parameters

    key

    The key for the receiver.

    Import Statement

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • Returns the object specifier in which an evaluation error occurred.

    Declaration

    Swift

    var evaluationErrorSpecifier: NSScriptObjectSpecifier? { get }

    Objective-C

    @property(readonly, retain) NSScriptObjectSpecifier *evaluationErrorSpecifier

    Return Value

    The object specifier in which an evaluation error occurred.

    Discussion

    The object specifier failing to evaluate could be the receiver or any container specifier “above” the receiver.

    Import Statement

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • Returns the constant identifying the type of error that caused evaluation to fail.

    Declaration

    Swift

    var evaluationErrorNumber: Int

    Objective-C

    @property NSInteger evaluationErrorNumber

    Return Value

    The constant identifying the type of error that caused evaluation to fail.

    Discussion

    This error code could be associated with the receiver or any container specifier “above” the receiver. Possible return values are defined in Constants.

    Import Statement

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • Sets the value of the evaluation error.

    Declaration

    Swift

    var evaluationErrorNumber: Int

    Objective-C

    @property NSInteger evaluationErrorNumber

    Parameters

    error

    The value for the evaluation error.

    Import Statement

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • Returns an Apple event descriptor that represents the receiver.

    Declaration

    Swift

    @NSCopying var descriptor: NSAppleEventDescriptor? { get }

    Objective-C

    @property(readonly, copy) NSAppleEventDescriptor *descriptor

    Return Value

    An Apple event descriptor of type typeObjectSpecifier.

    Discussion

    If the receiver was created with objectSpecifierWithDescriptor:, the passed-in descriptor is returned. Otherwise, a new descriptor is created and returned, autoreleased.

    Import Statement

    import Foundation

    Availability

    Available in OS X v10.5 and later.

  • NSScriptObjectSpecifier provides the following constants for error codes for specific problems evaluating specifiers:

    Declaration

    Swift

    var NSNoSpecifierError: Int { get } var NSNoTopLevelContainersSpecifierError: Int { get } var NSContainerSpecifierError: Int { get } var NSUnknownKeySpecifierError: Int { get } var NSInvalidIndexSpecifierError: Int { get } var NSInternalSpecifierError: Int { get } var NSOperationNotSupportedForKeySpecifierError: Int { get }

    Objective-C

    enum { NSNoSpecifierError = 0, NSNoTopLevelContainersSpecifierError, NSContainerSpecifierError, NSUnknownKeySpecifierError, NSInvalidIndexSpecifierError, NSInternalSpecifierError, NSOperationNotSupportedForKeySpecifierError };

    Constants

    • NSNoSpecifierError

      NSNoSpecifierError

      No error encountered.

      Available in OS X v10.0 and later.

    • NSNoTopLevelContainersSpecifierError

      NSNoTopLevelContainersSpecifierError

      Someone called evaluate with nil.

      Available in OS X v10.0 and later.

    • NSContainerSpecifierError

      NSContainerSpecifierError

      Error evaluating container specifier.

      Available in OS X v10.0 and later.

    • NSUnknownKeySpecifierError

      NSUnknownKeySpecifierError

      Receivers do not understand the key.

      Available in OS X v10.0 and later.

    • NSInvalidIndexSpecifierError

      NSInvalidIndexSpecifierError

      Index out of bounds.

      Available in OS X v10.0 and later.

    • NSInternalSpecifierError

      NSInternalSpecifierError

      Other internal error.

      Available in OS X v10.0 and later.

    • NSOperationNotSupportedForKeySpecifierError

      NSOperationNotSupportedForKeySpecifierError

      Attempt made to perform an unsupported operation on some key.

      Available in OS X v10.0 and later.

    Import Statement