<!--
{
  "availability" : [
    "iOS: 4.0.0 -",
    "iPadOS: 4.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.6.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreFoundation",
  "identifier" : "/documentation/CoreFoundation/CFDataFind(_:_:_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Core Foundation"
    ],
    "preciseIdentifier" : "c:@F@CFDataFind"
  },
  "title" : "CFDataFind(_:_:_:_:)"
}
-->

# CFDataFind(_:_:_:_:)

Finds and returns the range within a data object of the first occurrence of the given data, within a given range, subject to any given options.

```
func CFDataFind(_ theData: CFData!, _ dataToFind: CFData!, _ searchRange: CFRange, _ compareOptions: CFDataSearchFlags) -> CFRange
```

## Parameters

`theData`

The data object within which to search.

`dataToFind`

The data to find. Must not be `NULL`.

`searchRange`

The range within `theData` to be searched.

`compareOptions`

A bit mask specifying search options. The [`CFDataSearchFlags`](/documentation/CoreFoundation/CFDataSearchFlags) options can be specified singly or combined with the C bitwise `OR` operator

## Return Value

The range representing the location and length of `dataToFind` within `searchRange`, modulo the options in `compareOptions`. The range returned is relative to the start of the searched data, not the passed-in search range. Returns [`kCFNotFound`](/documentation/CoreFoundation/kCFNotFound) if `dataToFind` is not found.

## Discussion

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)