Mac Developer Library

Developer

Foundation Framework Reference NSSpecifierTest Class Reference

Options
Deployment Target:

On This Page
Language:

NSSpecifierTest

Inheritance


Conforms To


Import Statement


Swift

import Foundation

Objective-C

@import Foundation;

Availability


Available in OS X v10.0 and later.

Instances of this class represent a Boolean expression; they evaluate an object specifier and compare the resulting object to another object using a given comparison method. For more information on NSSpecifierTest, see the method description for its sole public method, its initializer, initWithObjectSpecifier:comparisonOperator:testObject:.

When an NSSpecifierTest object is properly initialized, it holds two objects:

  • A “value” or “test” object used as the basis of the comparison; this object can be a regular object or object specifier (such as “blue” in “words whose color is blue”).

  • An object specifier evaluating to the container (“words”).

The instance also encapsulates a selector identifying the method performing this comparison. The informal protocol NSComparisonMethods defines a set of comparison methods useful for this purpose, while NSScriptingComparisonMethods describes additional methods you may need to use for scripting.

The test object is compared, using the selector, against each object in the container. Specifiers in these tests usually have containerIsObjectBeingTested invoked on their topmost container.

You should rarely need to subclass NSSpecifierTest.

Data Types

  • These are passed to initWithObjectSpecifier:comparisonOperator:testObject: to specify the comparison operator.

    Declaration

    Swift

    enum NSTestComparisonOperation : UInt { case EqualToComparison case LessThanOrEqualToComparison case LessThanComparison case GreaterThanOrEqualToComparison case GreaterThanComparison case BeginsWithComparison case EndsWithComparison case ContainsComparison }

    Objective-C

    typedef enum { NSEqualToComparison = 0, NSLessThanOrEqualToComparison, NSLessThanComparison, NSGreaterThanOrEqualToComparison, NSGreaterThanComparison, NSBeginsWithComparison, NSEndsWithComparison, NSContainsComparison } NSTestComparisonOperation;

    Constants

    • EqualToComparison

      NSEqualToComparison

      Binary comparison operator that results in YEStrue if the two objects are equal.

      Available in OS X v10.0 and later.

    • LessThanOrEqualToComparison

      NSLessThanOrEqualToComparison

      Binary comparison operator that results in YEStrue if the value of the test object is equal to or less than the value of the other object.

      Available in OS X v10.0 and later.

    • LessThanComparison

      NSLessThanComparison

      Binary comparison operator that results in YEStrue if the value of the test object is less than the value of the other object.

      Available in OS X v10.0 and later.

    • GreaterThanOrEqualToComparison

      NSGreaterThanOrEqualToComparison

      Binary comparison operator that results in YEStrue if the value of the test object is greater than or equal to the value of the other object.

      Available in OS X v10.0 and later.

    • GreaterThanComparison

      NSGreaterThanComparison

      Binary comparison operator that results in YEStrue if the value of the test object is greater than the value of the other object.

      Available in OS X v10.0 and later.

    • BeginsWithComparison

      NSBeginsWithComparison

      Binary containment operator that results in YEStrue if the test object is a list or string that matches the beginning of the other object (which is also a list or string).

      Available in OS X v10.0 and later.

    • EndsWithComparison

      NSEndsWithComparison

      Binary containment operator that results in YEStrue if the test object is a list or string that matches the end of the other object (which is also a list or string).

      Available in OS X v10.0 and later.

    • ContainsComparison

      NSContainsComparison

      Binary containment operator that results in YEStrue if the test object is a list or string that matches the other object (which is also a list or string) at any location.

      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.