Next Page > Hide TOC

NSScriptingComparisonMethods Protocol Reference

(informal protocol)

Framework
/System/Library/Frameworks/Foundation.framework
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
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
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
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
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
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
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
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
Declared In
NSScriptWhoseTests.h

Next Page > Hide TOC


© 2006 Apple Computer, Inc. All Rights Reserved. (Last updated: 2006-05-23)


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.