(informal protocol)
Framework | /System/Library/Frameworks/Foundation.framework |
Companion guide | |
Declared in | NSScriptWhoseTests.h |
This informal protocol defines a set of default comparison methods useful for the comparisons in NSSpecifierTest
.
If you have scriptable objects that need to perform comparisons for scripting purposes, you may need to implement some of the methods declared in NSScriptingComparisonMethods
. The default implementation provided for many of these methods by NSObject
is appropriate for objects that implement a single comparison method whose selector, signature, and description match the following:
- (NSComparisonResult)compare:(id)object; |
This method should return NSOrderedAscending
if the receiver is less than object, NSOrderedDescending
if the receiver is greater than object, and NSOrderedSame
if the receiver and object are equal. For example, NSString
does not implement most of the methods declared in this informal protocol, but NSString
objects still handle messages conforming to this protocol properly because NSString
implements a compare:
method that meets the necessary requirements. Cocoa also includes appropriate compare:
method implementations for the NSDate
, NSDecimalNumber
, and NSValue
classes.
– doesContain:
– isCaseInsensitiveLike:
– isEqualTo:
– isGreaterThan:
– isGreaterThanOrEqualTo:
– isLessThan:
– isLessThanOrEqualTo:
– isLike:
– isNotEqualTo:
Returns a Boolean value that indicates whether the receiver contains a given object.
- (BOOL)doesContain:(id)object
The object to search for in the receiver.
YES
if the receiver contains object, otherwise NO
.
Currently, doesContain:
messages are never sent to any object from within Cocoa itself.
The default implementation for this method provided by NSObject
returns YES
if the receiver is actually an NSArray
object and an indexOfObjectIdenticalTo:
message sent to the same object would return something other than NSNotFound
.
NSScriptWhoseTests.h
Returns a Boolean value that indicates whether receiver is considered to be “like” a given string when the case of characters in the receiver is ignored.
- (BOOL)isCaseInsensitiveLike:(NSString *)aString
The string with which to compare the receiver.
YES
if the receiver is considered to be “like” aString when the case of characters in the receiver is ignored, otherwise NO
.
Currently, isCaseInsensitiveLike:
messages are never sent to any object from within Cocoa itself.
The default implementation for this method provided by NSObject
returns NO
. NSString
also provides an implementation of this method, which returns YES
if the receiver matches a pattern described by aString, ignoring the case of the characters in the receiver.
NSScriptWhoseTests.h
Returns a Boolean value that indicates whether the receiver is equal to another given object.
- (BOOL)isEqualTo:(id)object
The object with which to compare the receiver.
YES
if the receiver is equal to object, otherwise NO
. In effect returns NO
if receiver is nil
.
During the evaluation of an NSWhoseSpecifier
object that contains a test whose operator is NSEqualToComparison
, an isEqualTo:
message may be sent to each potentially specified object, if neither the potentially specified object nor the object being tested against implements a scriptingIsEqualTo:
method.
The default implementation for this method provided by NSObject
returns YES
if an isEqualTo:
message sent to the same object would return YES
.
NSScriptWhoseTests.h
Returns a Boolean value that indicates whether the receiver is greater than another given object.
- (BOOL)isGreaterThan:(id)object
The object with which to compare the receiver.
YES
if the receiver is greater than object, otherwise NO
.
During the evaluation of an NSWhoseSpecifier
object that contains a test whose operator is NSGreaterThanComparison
, an isGreaterThan:
message may be sent to each potentially specified object, if the potentially specified object does not implement a scriptingIsGreaterThan:
method and the object being tested against does not implement a scriptingIsLessThanOrEqualTo:
method.
The default implementation for this method provided by NSObject
returns YES
if a compare:
message sent to the same object would return NSOrderedDescending
.
NSScriptWhoseTests.h
Returns a Boolean value that indicates whether the receiver is greater than or equal to another given object.
- (BOOL)isGreaterThanOrEqualTo:(id)object
The object with which to compare the receiver.
YES
if the receiver is greater than or equal to object, otherwise NO
.
During the evaluation of an NSWhoseSpecifier
object that contains a test whose operator is NSGreaterThanOrEqualToComparison
, anisGreaterThanOrEqualTo:
message may be sent to each potentially specified object, if the potentially specified object does not implement a scriptingIsGreaterThanOrEqualTo:
method and the object being tested against does not implement a scriptingIsLessThan:
method.
The default implementation for this method provided by NSObject
returns YES
if a compare:
message sent to the same object would return NSOrderedSame
or NSOrderedDescending
.
NSScriptWhoseTests.h
Returns a Boolean value that indicates whether the receiver is less than another given object.
- (BOOL)isLessThan:(id)object
The object with which to compare the receiver.
YES
if the receiver is less than object, otherwise NO
.
During the evaluation of an NSWhoseSpecifier
object that contains a test whose operator is NSLessThanComparison
, an isLessThan:
message may be sent to each potentially specified object, if the potentially specified object does not implement a scriptingIsLessThan:
method and the object being tested against does not implement a scriptingIsGreaterThanOrEqualTo:
method.
The default implementation for this method provided by NSObject
method returns YES
if a compare:
message sent to the same object would return NSOrderedAscending
.
NSScriptWhoseTests.h
Returns a Boolean value that indicates whether the receiver is less than or equal to another given object.
- (BOOL)isLessThanOrEqualTo:(id)object
The object with which to compare the receiver.
YES
if the receiver is less than or equal to object, otherwise NO
.
During the evaluation of an NSWhoseSpecifier
object that contains a test whose operator is NSLessThanOrEqualToComparison
, an isLessThanOrEqualTo:
message may be sent to each potentially specified object, if the potentially specified object does not implement a scriptingIsLessThanOrEqualTo:
method and the object being tested against does not implement a scriptingIsGreaterThan:
method.
The default implementation for this method provided by NSObject
method returns YES
if a compare:
message sent to the same object would return NSOrderedAscending
or NSOrderedSame
.
NSScriptWhoseTests.h
Returns a Boolean value that indicates whether the receiver is "like" another given object.
- (BOOL)isLike:(NSString *)object
The object with which to compare the receiver.
YES
if the receiver is considered to be “like” object, otherwise NO
.
Currently, isLike:
messages are never sent to any object from within Cocoa itself.
The default implementation for this method provided by NSObject
method returns NO
. NSString
also provides an implementation of this method, which returns YES
if the receiver matches a pattern described by object.
NSScriptWhoseTests.h
Returns a Boolean value that indicates whether the receiver is not equal to another given object.
- (BOOL)isNotEqualTo:(id)object
The object with which to compare the receiver.
YES
if the receiver is not equal to object, otherwise NO
.
Currently, isNotEqualTo:
messages are never sent to any object from within Cocoa itself.
The default implementation for this method provided by NSObject
method returns YES
if an isEqual:
message sent to the same object would return NO
.
NSScriptWhoseTests.h
© 2006 Apple Computer, Inc. All Rights Reserved. (Last updated: 2006-05-23)