Instance Method


Returns a Boolean value that indicates whether a given string is equal to the receiver using a literal Unicode-based comparison.


- (BOOL)isEqualToString:(NSString *)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.


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).

Special Considerations

When you know both objects are strings, this method is a faster way to check equality than isEqual:.

See Also

Identifying and Comparing Strings

- caseInsensitiveCompare:

Returns the result of invoking compare:options: with NSCaseInsensitiveSearch as the only option.

- localizedCaseInsensitiveCompare:

Compares the string with a given string using a case-insensitive, localized, comparison.

- compare:

Returns the result of invoking compare:options:range: with no options and the receiver’s full extent as the range.

- localizedCompare:

Compares the string and a given string using a localized comparison.

- compare:options:

Compares the string with the specified string using the given options.

- compare:options:range:

Returns the result of invoking compare:options:range:locale: with a nil locale.

- compare:options:range:locale:

Compares the string using the specified options and returns the lexical ordering for the range.

- localizedStandardCompare:

Compares strings as sorted by the Finder.

- hasPrefix:

Returns a Boolean value that indicates whether a given string matches the beginning characters of the receiver.

- hasSuffix:

Returns a Boolean value that indicates whether a given string matches the ending characters of the receiver.


An unsigned integer that can be used as a hash table address.


These values represent the options available to many of the string classes’ search and comparison methods.


Options for converting string encodings.