---
title: "caseInsensitiveCompare(_:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nsstring/caseinsensitivecompare(_:)"
---

# caseInsensitiveCompare(_:)

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

## Declaration

```swift
func caseInsensitiveCompare(_ string: String) -> ComparisonResult
```

## Parameters

- `string`: The string with which to compare the receiver.

## Return Value

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

## Discussion

Discussion This method is the equivalent of invoking compare(_:options:) with caseInsensitive as the only option. important: When working with text that’s presented to the user, use the localizedCaseInsensitiveCompare(_:) method instead.

## See Also

### Identifying and Comparing Strings

- [localizedCaseInsensitiveCompare(_:)](foundation/nsstring/localizedcaseinsensitivecompare(_:).md)
- [compare(_:)](foundation/nsstring/compare(_:).md)
- [localizedCompare(_:)](foundation/nsstring/localizedcompare(_:).md)
- [compare(_:options:)](foundation/nsstring/compare(_:options:).md)
- [compare(_:options:range:)](foundation/nsstring/compare(_:options:range:).md)
- [compare(_:options:range:locale:)](foundation/nsstring/compare(_:options:range:locale:).md)
- [localizedStandardCompare(_:)](foundation/nsstring/localizedstandardcompare(_:).md)
- [hasPrefix(_:)](foundation/nsstring/hasprefix(_:).md)
- [hasSuffix(_:)](foundation/nsstring/hassuffix(_:).md)
- [isEqual(to:)](foundation/nsstring/isequal(to:).md)
- [hash](foundation/nsstring/hash.md)
- [NSString.CompareOptions](foundation/nsstring/compareoptions.md)
- [NSString.EncodingConversionOptions](foundation/nsstring/encodingconversionoptions.md)
