Mac Developer Library

Developer

Foundation Framework Reference NSScriptObjectSpecifiers Protocol Reference

Options
Deployment Target:

On This Page
Language:

NSScriptObjectSpecifiers

Informal protocol. Allows scriptable objects that can provide a fully specified object specifier to themselves within an application to do so. It also enables containers of objects to perform their own specifier evaluation.

For a comprehensive treatment of object specifiers, including sample code, see Object Specifiers in Cocoa Scripting Guide.

Inheritance


Not Applicable

Conforms To


Not Applicable

Import Statement


Swift

import Foundation

Objective-C

@import Foundation;

Availability


Available in OS X v10.0 and later.
  • Returns an object specifier for the receiver.

    Declaration

    Swift

    var objectSpecifier: NSScriptObjectSpecifier! { get }

    Objective-C

    @property(readonly, retain) NSScriptObjectSpecifier *objectSpecifier

    Return Value

    A fully specified object specifier to the receiver within the application.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • Returns the indices of the specified container objects.

    Declaration

    Swift

    func indicesOfObjectsByEvaluatingObjectSpecifier(_ specifier: NSScriptObjectSpecifier) -> [AnyObject]?

    Objective-C

    - (NSArray *)indicesOfObjectsByEvaluatingObjectSpecifier:(NSScriptObjectSpecifier *)specifier

    Parameters

    specifier

    An object specifier for the container objects for which to obtain the indices.

    Return Value

    A zero-based array of NSNumber objects that identify the zero-based indices of the container objects that match specifier, or nil if no matching objects were found.

    Discussion

    Containers that want to evaluate some specifiers on their own should implement this method. If this method returns nil, the object specifier will go on to do its own evaluation, so you should only return nil if that's the behavior you want, or if an error occurs. If this method returns an array, the object specifier will use the NSNumber objects in it as the indices. So, if you evaluate the specifier and there are no objects that match, you should return an empty array, not nil. If you find only one object, you should still return its index in an array. Returning an array with a single index where the index is –1 is interpreted to mean all the objects.

    For an example implementation, see "Implementing Object Specifiers" in Object Specifiers in Cocoa Scripting Guide

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.0 and later.