NSComparisonMethods

A collection of default comparison methods useful for performing specifier tests. 指定子テストを実行するのに有用な省略時の比較メソッドのいちコレクション。

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: スクリプティング目的のために比較の実行が必要なスクリプト対応オブジェクトをあなたが持つならば、あなたはNSScriptingComparisonMethodsにおいて宣言されるメソッドのいくつかを実装する必要があるでしょう。NSObjectによってこれらのメソッドの多くに対して提供される省略時実装は、単一の比較メソッドでそれのもつセレクタ、シグネチャ、そして説明が以下に合うものを実装するオブジェクトに適切です。


- (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. このメソッドは、レシーバがobjectより小さいならばNSOrderedAscending、レシーバがobjectより大きいならばNSOrderedDescending、そしてレシーバとobjectが等しいならばNSOrderedSameを返すべきです。例えば、NSStringはこの非形式プロトコルにおいて宣言されるメソッドのほとんどを実装しません、しかしNSStringオブジェクトはこのプロトコルに準拠するメッセージを依然として適切に取り扱います、なぜならNSStringは必要な要件を満たすcompare:メソッドを実装するからです。Cocoaはまた、適切なcompare:メソッド実装をNSDateNSDecimalNumber、そしてNSValueクラスのために含みます。

Topics 話題

Performing comparisons 比較を実行する

See Also 参照

NSObject Script Support NSObjectスクリプトサポート

Related Documentation 関連文書