Mac Developer Library

Developer

Foundation Framework Reference NSWhoseSpecifier Class Reference

Options
Deployment Target:

On This Page
Language:

NSWhoseSpecifier

NSWhoseSpecifier specifies every object in a collection (or every element in a container) that matches the condition defined by a single Boolean expression or multiple Boolean expressions connected by logical operators. NSWhoseSpecifier is unique among object specifiers in that its top-level container is typically not the application object but an evaluated object specifier involved in the tested-for condition. An NSWhoseSpecifier object encapsulates a “test” object for defining this condition. A test object is instantiated from a subclass of the abstract NSScriptWhoseTest class, whose one declared method is isTrue. See "Boolean Expressions and Logical Operations" in NSScriptObjectSpecifier and the descriptions in NSComparisonMethods and NSScriptingComparisonMethods for more information.

The set of elements specified by an NSWhoseSpecifier object can be a subset of those that pass the NSWhoseSpecifier object's test. This subset is specified by the various sub-element properties of the NSWhoseSpecifier object . Consider as an example the specifier paragraphs where color of third word is blue. This would be represented by an NSWhoseSpecifier object that uses a test specifier and another object specifier to identify a subset of the objects with the specified property. That is, the specifier’s property is paragraphs; the test specifier is an index specifier with property words and index 3; and the qualifier is a key value qualifier for key color and value [NSColor blueColor]. The test object specifier (word at index 3) is evaluated for each object (paragraph) using that object as the container; the resulting objects (if any) are tested with the qualifier (color blue).

NSWhoseSpecifier is part of Cocoa’s built-in script handling. You don’t normally subclass it.

Inheritance


Conforms To


Import Statement


Swift

import Foundation

Objective-C

@import Foundation;

Availability


Available in OS X v10.0 and later.
  • Returns the end sub-element identifier for the receiver.

    Declaration

    Swift

    var endSubelementIdentifier: NSWhoseSubelementIdentifier

    Objective-C

    @property NSWhoseSubelementIdentifier endSubelementIdentifier

    Return Value

    The end sub-element identifier for the receiver, or NSNoSubelement if there is none.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • Returns the index position of the last sub-element within the range of objects being tested that passes the receiver's test.

    Declaration

    Swift

    var endSubelementIndex: Int

    Objective-C

    @property NSInteger endSubelementIndex

    Return Value

    The index position of the last sub-element within the range of objects being tested that passes the receiver's test.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • Sets the end sub-element identifier for the specifier to the value of a given sub-element.

    Declaration

    Swift

    var endSubelementIdentifier: NSWhoseSubelementIdentifier

    Objective-C

    @property NSWhoseSubelementIdentifier endSubelementIdentifier

    Parameters

    subelement

    The end sub-element for the receiver.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • Sets the index position of the last sub-element within the range of objects being tested that pass the specifier’s test.

    Declaration

    Swift

    var endSubelementIndex: Int

    Objective-C

    @property NSInteger endSubelementIndex

    Parameters

    index

    The index position of the end sub-element.

    Discussion

    Used only if the end sub-element identifier is NSIndexSubelement.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • Sets the start sub-element identifier for the specifier.

    Declaration

    Swift

    var startSubelementIdentifier: NSWhoseSubelementIdentifier

    Objective-C

    @property NSWhoseSubelementIdentifier startSubelementIdentifier

    Parameters

    subelement

    The start sub-element for the receiver.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • Sets the index position of the first sub-element within the range of objects being tested that passes the specifier’s test.

    Declaration

    Swift

    var startSubelementIndex: Int

    Objective-C

    @property NSInteger startSubelementIndex

    Parameters

    index

    The index position of the start sub-element.

    Discussion

    Used only if the start sub-element identifier is NSIndexSubelement.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • Sets the test object that is encapsulated by the receiver.

    Declaration

    Swift

    var test: NSScriptWhoseTest?

    Objective-C

    @property(retain) NSScriptWhoseTest *test

    Parameters

    test

    The test object for the receiver.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • Returns the start sub-element identifier for the receiver.

    Declaration

    Swift

    var startSubelementIdentifier: NSWhoseSubelementIdentifier

    Objective-C

    @property NSWhoseSubelementIdentifier startSubelementIdentifier

    Return Value

    The start sub-element identifier for the receiver.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • Returns the index position of the first sub-element within the range of objects being tested that pass the receiver's test.

    Declaration

    Swift

    var startSubelementIndex: Int

    Objective-C

    @property NSInteger startSubelementIndex

    Return Value

    The index position of the first sub-element within the range of objects being tested that pass the receiver's test.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.0 and later.

  • Returns the test object encapsulated by the receiver.

    Declaration

    Swift

    var test: NSScriptWhoseTest?

    Objective-C

    @property(retain) NSScriptWhoseTest *test

    Return Value

    The test object encapsulated by the receiver.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.0 and later.

Data Types

  • NSWhoseSpecifier uses these constants to specify sub-elements within the collection of objects being tested that pass the specifier’s test.

    Declaration

    Swift

    enum NSWhoseSubelementIdentifier : UInt { case IndexSubelement case EverySubelement case MiddleSubelement case RandomSubelement case NoSubelement }

    Objective-C

    typedef enum { NSIndexSubelement = 0, NSEverySubelement = 1, NSMiddleSubelement = 2, NSRandomSubelement = 3, NSNoSubelement = 4 } NSWhoseSubelementIdentifier;

    Constants

    • IndexSubelement

      NSIndexSubelement

      An element at a given index that meets the specifier test.

      Available in OS X v10.0 and later.

    • EverySubelement

      NSEverySubelement

      Every element that meets the specifier test.

      Available in OS X v10.0 and later.

    • MiddleSubelement

      NSMiddleSubelement

      The middle element that meets the specifier test.

      Available in OS X v10.0 and later.

    • RandomSubelement

      NSRandomSubelement

      Any element that meets the specifier test.

      Available in OS X v10.0 and later.

    • NoSubelement

      NSNoSubelement

      No sub-element met the specifier test. Valid only for specifying the end sub-element.; that is, there is no end, so consider all elements.

      Available in OS X v10.0 and later.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.0 and later.