<!--
{
  "availability" : [
    "iOS: 2.0.0 - 27.0.0",
    "iPadOS: 2.0.0 - 27.0.0",
    "macCatalyst: 13.1.0 - 27.0.0",
    "macOS: 10.4.0 - 27.0.0",
    "tvOS: 9.0.0 - 27.0.0",
    "visionOS: 1.0.0 - 27.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "CFNetwork",
  "identifier" : "/documentation/CFNetwork/CFNetServiceGetTXTData(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "CFNetwork"
    ],
    "preciseIdentifier" : "c:@F@CFNetServiceGetTXTData"
  },
  "title" : "CFNetServiceGetTXTData(_:)"
}
-->

# CFNetServiceGetTXTData(_:)

Queries a network service for the contents of its TXT records.

```
func CFNetServiceGetTXTData(_ theService: CFNetService) -> Unmanaged<CFData>?
```

## Parameters

`theService`

Reference for the network service whose TXT record data is to be obtained; cannot be `NULL`. Note that in order to get TXT record data, you must resolve `theService` by calling [`CFNetServiceResolve`](/documentation/CFNetwork/CFNetServiceResolve) or [`CFNetServiceResolveWithTimeout(_:_:_:)`](/documentation/CFNetwork/CFNetServiceResolveWithTimeout(_:_:_:)) before calling this function.

## Return Value

CFDataRef object containing the requested TXT data and suitable for passing to [`CFNetServiceCreateDictionaryWithTXTData(_:_:)`](/documentation/CFNetwork/CFNetServiceCreateDictionaryWithTXTData(_:_:)), or `NULL` if the service’s TXT data has not been resolved.

## Discussion

This function gets the data from the service’s TXT records.

### Special Considerations

This function gets the data in a thread-safe way, but the data itself is not safe if the service is altered from another thread.

---

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)