Instance Method

compare(_:)

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

Declaration

func compare(_ string: String) -> ComparisonResult

Parameters

aString

The string with which to compare the receiver.

This value must not be nil. If this value is nil, the behavior is undefined and may change in future versions of macOS.

Return Value

Returns an ComparisonResult value that indicates the lexical ordering. orderedAscending the receiver precedes aString in lexical ordering, orderedSame the receiver and aString are equivalent in lexical value, and orderedDescending if the receiver follows aString.

Discussion

This method is equivalent to invoking compare(_:options:range:) with no options and the receiver’s full extent as the range.

See Also

Related Symbols

func isEqual(to: String)

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

func compare(String, options: NSString.CompareOptions = [])

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

func localizedStandardCompare(String)

Compares strings as sorted by the Finder.