NSScriptingComparisonMethods Protocol Reference

(informal protocol)

Framework
/System/Library/Frameworks/Foundation.framework
Availability
Available in OS X v10.0 and later.
Companion guide
Declared in
NSScriptWhoseTests.h

Overview

This informal protocol defines a set of methods useful for comparing script objects.

Often the correct way to compare two objects for scripting is different from the correct way to compare objects programmatically. This informal protocol defines a set of methods that can be implemented to perform a comparison appropriate for scripting that is independent of other methods for doing comparisons.

Cocoa scripting uses these scripting comparison methods, if available, in the process of evaluating specifier tests. If the first object being tested implements the appropriate method for the comparison operation, it will be used. If the first object doesn’t implement the appropriate method but the second object implements the inverse, the inverted comparison is performed. For example, instead of determining whether object one is less than object two, Cocoa determines whether object two is greater than object one (but only for the operations is equal, is less than or equal, is less than, is greater than or equal, or is greater than). If neither of the objects implements the appropriate method, Cocoa falls back on similar comparison operators in the protocol NSComparisonMethods (but again, only for the operations is equal, is less than or equal, is less than, is greater than or equal, or is greater than).

Cocoa provides default implementations of these scripting comparison methods for NSString and NSAttributedString. You should define implementations of these methods for any of your scriptable objects that need to perform comparisons for scripting purposes that are different than the comparisons provided by NSComparisonMethods. If none require different comparison methods, you can implement only the methods you need from NSScriptingComparisonMethods.

Tasks

Performing Comparisons

Instance Methods

scriptingBeginsWith:

Returns YES if, in a scripting comparison, the compared object matches the beginning of object. A default implementation is provided for NSString and NSAttributedString.

- (BOOL)scriptingBeginsWith:(id)object
Availability
  • Available in OS X v10.0 and later.
Declared In
NSScriptWhoseTests.h

scriptingContains:

Returns YES if, in a scripting comparison, the compared object contains object. A default implementation is provided for NSString and NSAttributedString.

- (BOOL)scriptingContains:(id)object
Availability
  • Available in OS X v10.0 and later.
Declared In
NSScriptWhoseTests.h

scriptingEndsWith:

Returns YES if, in a scripting comparison, the compared object matches the end of object. A default implementation is provided for NSString and NSAttributedString.

- (BOOL)scriptingEndsWith:(id)object
Availability
  • Available in OS X v10.0 and later.
Declared In
NSScriptWhoseTests.h

scriptingIsEqualTo:

Returns YES if, in a scripting comparison, the compared object is equal to object. A default implementation is provided for NSString and NSAttributedString.

- (BOOL)scriptingIsEqualTo:(id)object
Availability
  • Available in OS X v10.0 and later.
Declared In
NSScriptWhoseTests.h

scriptingIsGreaterThan:

Returns YES if, in a scripting comparison, the compared object is greater than object. A default implementation is provided for NSString and NSAttributedString.

- (BOOL)scriptingIsGreaterThan:(id)object
Availability
  • Available in OS X v10.0 and later.
Declared In
NSScriptWhoseTests.h

scriptingIsGreaterThanOrEqualTo:

Returns YES if, in a scripting comparison, the compared object is greater than or equal to object. A default implementation is provided for NSString and NSAttributedString.

- (BOOL)scriptingIsGreaterThanOrEqualTo:(id)object
Availability
  • Available in OS X v10.0 and later.
Declared In
NSScriptWhoseTests.h

scriptingIsLessThan:

Returns YES if, in a scripting comparison, the compared object is less than object. A default implementation is provided for NSString and NSAttributedString.

- (BOOL)scriptingIsLessThan:(id)object
Availability
  • Available in OS X v10.0 and later.
Declared In
NSScriptWhoseTests.h

scriptingIsLessThanOrEqualTo:

Returns YES if, in a scripting comparison, the compared object is less than or equal to object. A default implementation is provided for NSString and NSAttributedString.

- (BOOL)scriptingIsLessThanOrEqualTo:(id)object
Availability
  • Available in OS X v10.0 and later.
Declared In
NSScriptWhoseTests.h