---
title: "CFStringCompare(_:_:_:)"
framework: corefoundation
role: symbol
role_heading: Function
path: "corefoundation/cfstringcompare(_:_:_:)"
---

# CFStringCompare(_:_:_:)

Compares one string with another string.

## Declaration

```swift
func CFStringCompare(_ theString1: CFString!, _ theString2: CFString!, _ compareOptions: CFStringCompareFlags) -> CFComparisonResult
```

## Parameters

- `theString1`: The first string to use in the comparison.
- `theString2`: The second string to use in the comparison.
- `compareOptions`: Flags that select different types of comparisons, such as localized comparison, case-insensitive comparison, and non-literal comparison. If you want the default comparison behavior, pass 0. See doc://com.apple.corefoundation/documentation/CoreFoundation/string-comparison-flags for the available flags.

## Return Value

Return Value A CFComparisonResult value that indicates whether theString1 is equal to, less than, or greater than theString2.

## Discussion

Discussion You can affect how the comparison proceeds by specifying one or more option flags in compareOptions. Not all comparison options are currently implemented.

## See Also

### Comparing Strings

- [CFStringCompareWithOptions(_:_:_:_:)](corefoundation/cfstringcomparewithoptions(_:_:_:_:).md)
- [CFStringCompareWithOptionsAndLocale(_:_:_:_:_:)](corefoundation/cfstringcomparewithoptionsandlocale(_:_:_:_:_:).md)
- [CFStringHasPrefix(_:_:)](corefoundation/cfstringhasprefix(_:_:).md)
- [CFStringHasSuffix(_:_:)](corefoundation/cfstringhassuffix(_:_:).md)
