It seems that making a NWBrowser utilizing .bonjour
will by no means provide the TXT data, and can all the time return nil. Nonetheless, in case you use .bonjourWithTXTRecord
when creating your NWBrowser, you’ll get the TXT data as effectively.
Moreover, for some purpose it is advisable to undergo the consequence.metadata
as an alternative of the consequence.endpoint.txtRecord
to get the precise data.
Beneath is an instance of this in motion.
let browser = NWBrowser(for: .bonjourWithTXTRecord(kind: "_tictactoe._tcp", area: nil), utilizing: parameters)
browser.browseResultsChangedHandler = { outcomes, adjustments in
for lead to outcomes {
if case NWBrowser.Outcome.Metadata.bonjour(let txtRecord) = consequence.metadata {
print("Browser consequence with txt data: (txtRecord.dictionary)")
}
}
}