For the More Curious: TXTRecords

While Bonjour does not allow a client and server to exchange information, a service published via Bonjour can include additional information that can be read by clients. For example, a printer could tell clients that it is in the third-floor library, or a workstation could display the rules for using it. Every NSNetService has a TXT Record for this purpose.

You can create a TXT Record with an NSDictionary. This dictionary has some restrictions – its keys can only be NSStrings, and its values must be NSData objects that encapsulate an NSString or binary data. Once you have a valid dictionary, you pass it to the class method dataFromTXTRecordDictionary: of NSNetService and set it as an NSNetService’s TXTXRecordData ...

Get iOS Programming: The Big Nerd Ranch Guide, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.