---
title: "CFStringCreateArrayWithFindResults(_:_:_:_:_:)"
framework: corefoundation
role: symbol
role_heading: Function
path: "corefoundation/cfstringcreatearraywithfindresults(_:_:_:_:_:)"
---

# CFStringCreateArrayWithFindResults(_:_:_:_:_:)

Searches a string for multiple occurrences of a substring and creates an array of ranges identifying the locations of these substrings within the target string.

## Declaration

```swift
func CFStringCreateArrayWithFindResults(_ alloc: CFAllocator!, _ theString: CFString!, _ stringToFind: CFString!, _ rangeToSearch: CFRange, _ compareOptions: CFStringCompareFlags) -> CFArray!
```

## Parameters

- `alloc`: The allocator to use to allocate memory for the new CFArray object. Pass NULL or doc://com.apple.corefoundation/documentation/CoreFoundation/kCFAllocatorDefault to use the current default allocator.
- `theString`: The string in which to search for stringToFind.
- `stringToFind`: The string to search for in theString.
- `rangeToSearch`: The range of characters within theString to be searched. The specified range must not exceed the length of the string.
- `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 An array that contains pointers to CFRange structures identifying the character locations of stringToFind in theString. Returns NULL, if no matching substring is found in the source object, or if there was a problem creating the array. Ownership follows the The Create Rule.

## See Also

### Searching Strings

- [CFStringFind(_:_:_:)](corefoundation/cfstringfind(_:_:_:).md)
- [CFStringFindCharacterFromSet(_:_:_:_:_:)](corefoundation/cfstringfindcharacterfromset(_:_:_:_:_:).md)
- [CFStringFindWithOptions(_:_:_:_:_:)](corefoundation/cfstringfindwithoptions(_:_:_:_:_:).md)
- [CFStringFindWithOptionsAndLocale(_:_:_:_:_:_:)](corefoundation/cfstringfindwithoptionsandlocale(_:_:_:_:_:_:).md)
- [CFStringGetLineBounds(_:_:_:_:_:)](corefoundation/cfstringgetlinebounds(_:_:_:_:_:).md)
