NSWhoseSpecifier 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 | NSScriptObjectSpecifiers.h |
Overview
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.
Instance Methods
endSubelementIdentifier
Returns the end sub-element identifier for the receiver.
Return Value
The end sub-element identifier for the receiver, or NSNoSubelement if there is none.
Availability
- Available in OS X v10.0 and later.
Declared In
NSScriptObjectSpecifiers.hendSubelementIndex
Returns the index position of the last sub-element within the range of objects being tested that passes the receiver's test.
Return Value
The index position of the last sub-element within the range of objects being tested that passes the receiver's test.
Availability
- Available in OS X v10.0 and later.
Declared In
NSScriptObjectSpecifiers.hinitWithContainerClassDescription:containerSpecifier:key:test:
Returns an NSWhoseSpecifier object initialized with the given attributes.
Parameters
- classDescription
Class description for the receiver's container object.
- specifier
An object specifier for the receiver's container object.
- property
The key for the property for which to test.
- test
The test condition.
Return Value
An NSWhoseSpecifier object initialized with the given attributes.
Discussion
Invokes the super class’s initWithContainerClassDescription:containerSpecifier:key: and sets the whose test condition to test.
Availability
- Available in OS X v10.0 and later.
Declared In
NSScriptObjectSpecifiers.hsetEndSubelementIdentifier:
Sets the end sub-element identifier for the specifier to the value of a given sub-element.
Parameters
- subelement
The end sub-element for the receiver.
Availability
- Available in OS X v10.0 and later.
Declared In
NSScriptObjectSpecifiers.hsetEndSubelementIndex:
Sets the index position of the last sub-element within the range of objects being tested that pass the specifier’s test.
Parameters
- index
The index position of the end sub-element.
Discussion
Used only if the end sub-element identifier is NSIndexSubelement.
Availability
- Available in OS X v10.0 and later.
Declared In
NSScriptObjectSpecifiers.hsetStartSubelementIdentifier:
Sets the start sub-element identifier for the specifier.
Parameters
- subelement
The start sub-element for the receiver.
Availability
- Available in OS X v10.0 and later.
Declared In
NSScriptObjectSpecifiers.hsetStartSubelementIndex:
Sets the index position of the first sub-element within the range of objects being tested that passes the specifier’s test.
Parameters
- index
The index position of the start sub-element.
Discussion
Used only if the start sub-element identifier is NSIndexSubelement.
Availability
- Available in OS X v10.0 and later.
Declared In
NSScriptObjectSpecifiers.hsetTest:
Sets the test object that is encapsulated by the receiver.
Parameters
- test
The test object for the receiver.
Availability
- Available in OS X v10.0 and later.
Declared In
NSScriptObjectSpecifiers.hstartSubelementIdentifier
Returns the start sub-element identifier for the receiver.
Return Value
The start sub-element identifier for the receiver.
Availability
- Available in OS X v10.0 and later.
Declared In
NSScriptObjectSpecifiers.hstartSubelementIndex
Returns the index position of the first sub-element within the range of objects being tested that pass the receiver's test.
Return Value
The index position of the first sub-element within the range of objects being tested that pass the receiver's test.
Availability
- Available in OS X v10.0 and later.
Declared In
NSScriptObjectSpecifiers.htest
Returns the test object encapsulated by the receiver.
Return Value
The test object encapsulated by the receiver.
Availability
- Available in OS X v10.0 and later.
Declared In
NSScriptObjectSpecifiers.hConstants
NSWhoseSubelementIdentifier
NSWhoseSpecifier uses these constants to specify sub-elements within the collection of objects being tested that pass the specifier’s test.
typedef enum {
NSIndexSubelement = 0,
NSEverySubelement = 1,
NSMiddleSubelement = 2,
NSRandomSubelement = 3,
NSNoSubelement = 4
} NSWhoseSubelementIdentifier;
Constants
NSIndexSubelementAn element at a given index that meets the specifier test.
Available in OS X v10.0 and later.
Declared in
NSScriptObjectSpecifiers.h.NSEverySubelementEvery element that meets the specifier test.
Available in OS X v10.0 and later.
Declared in
NSScriptObjectSpecifiers.h.NSMiddleSubelementThe middle element that meets the specifier test.
Available in OS X v10.0 and later.
Declared in
NSScriptObjectSpecifiers.h.NSRandomSubelementAny element that meets the specifier test.
Available in OS X v10.0 and later.
Declared in
NSScriptObjectSpecifiers.h.NSNoSubelementNo 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.
Declared in
NSScriptObjectSpecifiers.h.
Discussion
These constants are used by startSubelementIdentifier, setStartSubelementIdentifier:, endSubelementIdentifier, and setEndSubelementIdentifier:.
Availability
- Available in OS X v10.0 and later.
Declared In
NSScriptObjectSpecifiers.h© 2006 Apple Computer, Inc. All Rights Reserved. (Last updated: 2006-06-28)