Mac Developer Library

Developer

Foundation Framework Reference NSScriptingComparisonMethods Protocol Reference

Options
Deployment Target:

On This Page
Language:

NSScriptingComparisonMethods

Inheritance


Not Applicable

Conforms To


Not Applicable

Import Statement


Swift

import Foundation

Objective-C

@import Foundation;

Availability


Available in OS X v10.0 and later.

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.

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

    Declaration

    Swift

    func scriptingBeginsWith(_ object: AnyObject!) -> Bool

    Objective-C

    - (BOOL)scriptingBeginsWith:(id)object

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.0 and later.

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

    Declaration

    Swift

    func scriptingContains(_ object: AnyObject!) -> Bool

    Objective-C

    - (BOOL)scriptingContains:(id)object

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.0 and later.

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

    Declaration

    Swift

    func scriptingEndsWith(_ object: AnyObject!) -> Bool

    Objective-C

    - (BOOL)scriptingEndsWith:(id)object

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.0 and later.

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

    Declaration

    Swift

    func scriptingIsEqualTo(_ object: AnyObject!) -> Bool

    Objective-C

    - (BOOL)scriptingIsEqualTo:(id)object

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.0 and later.

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

    Declaration

    Swift

    func scriptingIsGreaterThan(_ object: AnyObject!) -> Bool

    Objective-C

    - (BOOL)scriptingIsGreaterThan:(id)object

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.0 and later.

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

    Declaration

    Swift

    func scriptingIsGreaterThanOrEqualTo(_ object: AnyObject!) -> Bool

    Objective-C

    - (BOOL)scriptingIsGreaterThanOrEqualTo:(id)object

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.0 and later.

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

    Declaration

    Swift

    func scriptingIsLessThan(_ object: AnyObject!) -> Bool

    Objective-C

    - (BOOL)scriptingIsLessThan:(id)object

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.0 and later.

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

    Declaration

    Swift

    func scriptingIsLessThanOrEqualTo(_ object: AnyObject!) -> Bool

    Objective-C

    - (BOOL)scriptingIsLessThanOrEqualTo:(id)object

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.0 and later.