NSComparison​Methods

This informal protocol defines a set of default comparison methods useful for the comparisons in NSSpecifier​Test.

Overview

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 NSOrdered​Ascending if the receiver is less than object, NSOrdered​Descending if the receiver is greater than object, and NSOrdered​Same 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, NSDecimal​Number, and NSValue classes.

Symbols

Performing comparisons

func does​Contain(Any)

Returns a Boolean value that indicates whether the receiver contains a given object.

func is​Case​Insensitive​Like(String)

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.

func is​Equal(to:​ Any?)

Returns a Boolean value that indicates whether the receiver is equal to another given object.

func is​Greater​Than(Any?)

Returns a Boolean value that indicates whether the receiver is greater than another given object.

func is​Greater​Than​Or​Equal(to:​ Any?)

Returns a Boolean value that indicates whether the receiver is greater than or equal to another given object.

func is​Less​Than(Any?)

Returns a Boolean value that indicates whether the receiver is less than another given object.

func is​Less​Than​Or​Equal(to:​ Any?)

Returns a Boolean value that indicates whether the receiver is less than or equal to another given object.

func is​Like(String)

Returns a Boolean value that indicates whether the receiver is "like" another given object.

func is​Not​Equal(to:​ Any?)

Returns a Boolean value that indicates whether the receiver is not equal to another given object.

See Also

Related Documentation