Instance Method インスタンスメソッド

isEqualToString:

Returns a Boolean value that indicates whether a given string is equal to the receiver using a literal Unicode-based comparison. あるブール値を返します、与えられた文字列がレシーバと等しいかどうかを指し示します、リテラルユニコード基盤の比較を使います。

Declaration 宣言

- (BOOL)isEqualToString:(NSString *)aString;

Parameters パラメータ

aString

The string with which to compare the receiver. レシーバと比較する文字列。

Return Value 戻り値

YES if aString is equivalent to the receiver (if they have the same id or if they are NSOrderedSame in a literal comparison), otherwise NO. YES、もしaStringがレシーバと等しいならば(それらが同じidを持つならばまたはそれらがリテラル比較においてNSOrderedSameならば)、そうでなければNO

Discussion 議論

The comparison uses the canonical representation of strings, which for a particular string is the length of the string plus the UTF-16 code units that make up the string. When this method compares two strings, if the individual Unicodes are the same, then the strings are equal, regardless of the backing store. “Literal” when applied to string comparison means that various Unicode decomposition rules are not applied and UTF-16 code units are individually compared. So, for instance, “Ö” represented as the composed character sequence “O” (U+004F LATIN CAPITAL LETTER O) and a combining diaeresis “¨” (U+0308 COMBINING DIAERESIS) would not compare equal to “Ö” represented as a single Unicode character (U+00D6 LATIN CAPITAL LETTER O WITH DIAERESIS). 比較は、文字列の正準表現を使います、それはある特定の文字列に対して、その文字列の長さに文字列を作り上げるUTF-16コード単位を足したものです。このメソッドが2つの文字列を比較するとき、個々のユニコードが同じならば、そのときそれら文字列は等しいです、バッキングストアに関係なく。“リテラル” は文字列比較に適用される場合、さまざまなユニコード分解規則が適用されないそしてUTF-16コード単位が個々に比較されることを意味します。それで、例えば、合成文字列シーケンス “O”(U+004F LATIN CAPITAL LETTER O)と結合分音記号 “¨”(U+0308 COMBINING DIAERESIS)として表される “Ö” は、単一のユニコード文字(U+00D6 LATIN CAPITAL LETTER O WITH DIAERESIS)として表される “Ö” と等しいと比較されないでしょう。

Special Considerations 特別な注意事項

When you know both objects are strings, this method is a faster way to check equality than isEqual:. あなたが両方のオブジェクトが文字列であることを知っている場合、このメソッドは同等性を調べるisEqual:より高速な方法です。

See Also 参照

Identifying and Comparing Strings 文字列を識別および比較する