<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Network",
  "identifier" : "/documentation/Network/NWTXTRecord",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Network"
    ],
    "preciseIdentifier" : "s:7Network11NWTXTRecordV"
  },
  "title" : "NWTXTRecord"
}
-->

# NWTXTRecord

A dictionary representing a TXT record in a DNS packet.

```
struct NWTXTRecord
```

## Topics

### Creating TXT Records

[`init([String : String])`](/documentation/Network/NWTXTRecord/init(_:)-566pd)

Initializes a TXT record with a dictionary of strings.

[`func removeEntry(key: String) -> Bool`](/documentation/Network/NWTXTRecord/removeEntry(key:))

Removes an entry from a TXT record dictionary.

[`func setEntry(NWTXTRecord.Entry, for: String) -> Bool`](/documentation/Network/NWTXTRecord/setEntry(_:for:))

Sets an entry in a TXT record dictionary.

[`enum Entry`](/documentation/Network/NWTXTRecord/Entry)

A type of entry in a TXT record dictionary.

### Examining TXT Records

[`func getEntry(for: String) -> NWTXTRecord.Entry?`](/documentation/Network/NWTXTRecord/getEntry(for:))

Accesses an entry in a TXT record dictionary.

[`subscript(String) -> String?`](/documentation/Network/NWTXTRecord/subscript(_:))

Get and set values in a TXT record dictionary, by keys.

[`var dictionary: [String : String]`](/documentation/Network/NWTXTRecord/dictionary)

The TXT record as a dictionary of strings.

### Initializers

[`init(Data)`](/documentation/Network/NWTXTRecord/init(_:)-30jy4)

[`init([String : Data])`](/documentation/Network/NWTXTRecord/init(_:)-69q7g)

Create an NWTXTRecord object from a Dictionary<String, Data>.

[`init([String : NWTXTRecord.Entry])`](/documentation/Network/NWTXTRecord/init(_:)-7cww7)

Create an NWTXTRecord object from a Dictionary<String, NWTXTRecord.Entry>.

### Instance Properties

[`var data: Data`](/documentation/Network/NWTXTRecord/data)

[`var dataDictionary: [String : Data]`](/documentation/Network/NWTXTRecord/dataDictionary)

Access the contents of an NWTXTRecord represented by a
Dictionary<String, Data>.

[`var entries: [String : NWTXTRecord.Entry]`](/documentation/Network/NWTXTRecord/entries)

Get all entries present in the TXT record.

## Relationships

### Conforms To

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Collection`](/documentation/Swift/Collection)

[`Equatable`](/documentation/Swift/Equatable)

[`Copyable`](/documentation/Swift/Copyable)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`Escapable`](/documentation/Swift/Escapable)

[`Sequence`](/documentation/Swift/Sequence)

[`Sendable`](/documentation/Swift/Sendable)

---

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)