---
title: "TXTRecordGetLength(_:)"
framework: dnssd
role: symbol
role_heading: Function
path: "dnssd/txtrecordgetlength(_:)"
---

# TXTRecordGetLength(_:)

Allows you to determine the length of the raw bytes within a TXTRecordRef.

## Declaration

```swift
func TXTRecordGetLength(_ txtRecord: UnsafePointer<TXTRecordRef>!) -> UInt16
```

## Parameters

- `txtRecord`: A TXTRecordRef initialized by calling TXTRecordCreate().

## Return Value

Return Value Returns the size of the raw bytes inside a TXTRecordRef which you can pass directly to DNSServiceRegister(_:_:_:_:_:_:_:_:_:_:_:_:) or to DNSServiceUpdateRecord(_:_:_:_:_:_:). Returns 0 if the TXTRecordRef is empty.

## See Also

### TXT Record Construction Functions

- [TXTRecordCreate(_:_:_:)](dnssd/txtrecordcreate(_:_:_:).md)
- [TXTRecordDeallocate(_:)](dnssd/txtrecorddeallocate(_:).md)
- [TXTRecordGetBytesPtr(_:)](dnssd/txtrecordgetbytesptr(_:).md)
- [TXTRecordRemoveValue(_:_:)](dnssd/txtrecordremovevalue(_:_:).md)
- [TXTRecordSetValue(_:_:_:_:)](dnssd/txtrecordsetvalue(_:_:_:_:).md)
