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

# CFURLGetByteRangeForComponent(_:_:_:)

Returns the range of the specified component in the bytes of a URL.

```
func CFURLGetByteRangeForComponent(_ url: CFURL!, _ component: CFURLComponentType, _ rangeIncludingSeparators: UnsafeMutablePointer<CFRange>!) -> CFRange
```

## Parameters

`url`

The URL containing `component`.

`component`

The type of component in `anURL` whose range you want to obtain. See [`CFURLComponentType`](/documentation/CoreFoundation/CFURLComponentType) for possible values.

`rangeIncludingSeparators`

Specifies the range of `component` including the sequences that separate component from the previous and next components. If there is no previous or next components, this function will match the range of the component itself. If `anURL` does not contain `component`, `rangeIncludingSeparators` is set to the location where the component would be inserted.

## Return Value

The range of bytes for `component` in the buffer returned by the [`CFURLGetBytes(_:_:_:)`](/documentation/CoreFoundation/CFURLGetBytes(_:_:_:)) function. If `anURL` does not contain `component`, the first part of the returned range is set to [`kCFNotFound`](/documentation/CoreFoundation/kCFNotFound).

## Discussion

This function is intended to be used in conjunction with the [`CFURLGetBytes(_:_:_:)`](/documentation/CoreFoundation/CFURLGetBytes(_:_:_:)) function, since the range returned is only applicable to the bytes returned by [`CFURLGetBytes(_:_:_:)`](/documentation/CoreFoundation/CFURLGetBytes(_:_:_:)).

---

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)