<!--
{
  "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/CFNetServiceSetTXTData(_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "CFNetwork"
    ],
    "preciseIdentifier" : "c:@F@CFNetServiceSetTXTData"
  },
  "title" : "CFNetServiceSetTXTData(_:_:)"
}
-->

# CFNetServiceSetTXTData(_:_:)

Sets the TXT record for a CFNetService.

```
func CFNetServiceSetTXTData(_ theService: CFNetService, _ txtRecord: CFData) -> Bool
```

## Parameters

`theService`

CFNetServiceRef for which a TXT record is to be set; cannot be `NULL`.

`txtRecord`

Contents of the TXT record that is to be set. The contents must not exceed 1450 bytes.

## Return Value

`TRUE` if the TXT record was set; otherwise, `FALSE`.

## Discussion

This function sets a TXT record for the specified service. If the service is currently registered on the network, the record is broadcast. Setting a TXT record on a service that is still being resolved is not allowed.

### Special Considerations

This function is thread safe.

---

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)