One Logo Pool Ball
Network · IOS API REFERENCE

NWTXTRecord

struct · iOS 13.0+ · SDK 27.1

struct NWTXTRecord

An NWTXTRecord is used to provide additional information about a service during advertisement or discovery. Set an NWTXTRecord on a network listener to provide additional information about the service it is advertising, or get an NWTXTRecord from a network browser's browse result to get more information about a discovered service.

Members (17)

get · iOS 13.0+

dictionary

TypeScript
get dictionary(): Record<string, string>
Swift declaration
var dictionary: [String : String] { get }

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

get · iOS 13.0+

startIndex

TypeScript
get startIndex(): NWTXTRecord_Index
Swift declaration
var startIndex: NWTXTRecord.Index { get }

The position of the first element in a nonempty collection. If the collection is empty, `startIndex` is equal to `endIndex`.

method · iOS 13.0+

removeEntry

TypeScript
removeEntry(key: string): boolean
Swift declaration
@discardableResult mutating func removeEntry(key: String) -> Bool

Remove an entry from the TXT Record. If an invalid key is provided, the remove will fail. - Parameter key: The key of the entry. - Returns: Whether the remove was successful. If an invalid key is provided, this value will be false.

get · iOS 26.4+

dataDictionary

TypeScript
get dataDictionary(): Record<string, ArrayBuffer>
Swift declaration
var dataDictionary: [String : Data] { get }

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

get · iOS 13.0+

debugDescription

TypeScript
get debugDescription(): string
Swift declaration
var debugDescription: String { get }

A textual representation of this instance, suitable for debugging. Calling this property directly is discouraged. Instead, convert an instance of any type to a string by using the `String(reflecting:)` initializer. This initializer works with any type, and uses the custom `debugDescription` property for types that conform to `CustomDebugStringConvertible`: struct Point: CustomDebugStringConvertible { let x: Int, y: Int var debugDescription: String { return "(\(x), \(y))" } } let p = Point(x: 21, y: 30) let s = String(reflecting: p) print(s) // Prints "(21, 30)" The conversion of `p` to a string in the assignment to `s` uses the `Point` type's `debugDescription` property.

get · iOS 16.0+

data

TypeScript
get data(): ArrayBuffer
Swift declaration
var data: Data { get }

Access the TXT record as raw data.

method · iOS 13.0+

index

TypeScript
index(i: NWTXTRecord_Index): NWTXTRecord_Index
Swift declaration
func index(after i: NWTXTRecord.Index) -> NWTXTRecord.Index

Returns the position immediately after the given index. The successor of an index must be well defined. For an index `i` into a collection `c`, calling `c.index(after: i)` returns the same index every time. - Parameter i: A valid index of the collection. `i` must be less than `endIndex`. - Returns: The index value immediately after `i`.

get · iOS 26.4+

entries

TypeScript
get entries(): Record<string, NWTXTRecord_Entry>
Swift declaration
var entries: [String : NWTXTRecord.Entry] { get }

Get all entries present in the TXT record. - Returns: A dictionary representing all entries in the TXT record, preserving original key case.

get · iOS 13.0+

endIndex

TypeScript
get endIndex(): NWTXTRecord_Index
Swift declaration
var endIndex: NWTXTRecord.Index { get }

The collection's "past the end" position---that is, the position one greater than the last valid subscript argument. When you need a range that includes the last element of a collection, use the half-open range operator (`..<`) with `endIndex`. The `..<` operator creates a range that doesn't include the upper bound, so it's always safe to use with `endIndex`. For example: let numbers = [10, 20, 30, 40, 50] if let index = numbers.firstIndex(of: 30) { print(numbers[index ..< numbers.endIndex]) } // Prints "[30, 40, 50]" If the collection is empty, `endIndex` is equal to `startIndex`.

method · iOS 13.0+

getEntry

TypeScript
getEntry(key: string): (NWTXTRecord_Entry) | null
Swift declaration
func getEntry(for key: String) -> NWTXTRecord.Entry?

Get an entry from the TXT Record. If an invalid key is provided, the return value will be nil. - Parameter key: The key of the entry. - Returns: The entry, or nil if the key is invalid or if they entry does not exist in the TXT Record.

method · iOS 13.0+

setEntry

TypeScript
setEntry(entry: NWTXTRecord_Entry, key: string): boolean
Swift declaration
@discardableResult mutating func setEntry(_ entry: NWTXTRecord.Entry, for key: String) -> Bool

Set entry into the TXT Record. The new entry will replace any previous entry whose key matches case-insensitively. If an invalid key is provided, the insert will fail. - Parameter entry: The entry to insert. - Returns: Whether the insert was successful. If an invalid key is provided, this value will be false.

init · iOS 16.0+

init

TypeScript
static init(data: ArrayBuffer): NWTXTRecord
Swift declaration
init(_ data: Data)

Create a new TXT record object from a buffer of bytes. If the buffer follows the key-value pair format as defined in RFC 1464, the TXT record object will be created as a dictionary. Otherwise, it is created as a TXT record buffer. - Parameter data: The raw data

init · iOS 13.0+

init

TypeScript
static init95449(dictionary?: Record<string, string>): NWTXTRecord
Swift declaration
init(_ dictionary: [String : String] = [:])

Create an NWTXTRecord object from a Dictionary<String, String>. Every value in a key-value pair will be converted and stored as UTF8 encoded Data. The default value is an empty dictionary. - Parameter dictionary: The Dictionary<String, String>.

init · iOS 26.4+

init

TypeScript
static init27839(dataDictionary: Record<string, ArrayBuffer>): NWTXTRecord
Swift declaration
init(_ dataDictionary: [String : Data])

Create an NWTXTRecord object from a Dictionary<String, Data>. Invalid keys will be ignored. - Parameter dictionary: The Dictionary<String, Data>.

init · iOS 26.4+

init

TypeScript
static init14563(entryDictionary: Record<string, NWTXTRecord_Entry>): NWTXTRecord
Swift declaration
init(_ entryDictionary: [String : NWTXTRecord.Entry])

Create an NWTXTRecord object from a Dictionary<String, NWTXTRecord.Entry>. Invalid keys will be ignored. - Parameter dictionary: The Dictionary<String, NWTXTRecord.Entry>.

subscript · iOS 13.0+

subscript

TypeScript
subscript(position: NWTXTRecord_Index): { "key": string; "value": NWTXTRecord_Entry }
Swift declaration
subscript(position: NWTXTRecord.Index) -> NWTXTRecord.Element { get }

Accesses the element at the specified position. The following example accesses an element of an array through its subscript to print its value: var streets = ["Adams", "Bryant", "Channing", "Douglas", "Evarts"] print(streets[1]) // Prints "Bryant" You can subscript a collection with any valid index other than the collection's end index. The end index refers to the position one past the last element of a collection, so it doesn't correspond with an element. - Parameter position: The position of the element to access. `position` must be a valid index of the collection that is not equal to the `endIndex` property. - Complexity: O(1)

subscript · iOS 13.0+

subscript

TypeScript
subscript75626(key: string): (string) | null
Swift declaration
subscript(key: String) -> String? { get set }

A convenience accessor for getting and setting entries on the TXT Record. txtRecord.removeValue(forKey: "key") // removes the entry mapped to "key" ... txtRecord["key"] = "data" // replaces the previous entry mapped to "key" with "data" ... let value = txtRecord["key"] // gets the string mapped to "key", nil otherwise - Parameter key: The key of the entry.

Skipped declarations

No declarations were skipped in this snapshot.

All Network types →