Skip to content

Instantly share code, notes, and snippets.

Created March 18, 2012 18:18
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Add a TXTRecord using Bonjour and MonoTouch
NetDelegate _netDel;
NSNetService _ns;
void InitNetService ()
_ns = new NSNetService ("", "_testservice._tcp", UIDevice.CurrentDevice.Name, 9999);
_netDel = new NetDelegate ();
_ns.Delegate = _netDel;
// add TXTRecordData
var s = new NSString ("Bonjour from MonoTouch");
var dictionary = NSDictionary.FromObjectAndKey (s, new NSString ("myKey"));
var record = NSNetService.DataFromTxtRecord (dictionary);
_ns.TxtRecordData = record;
_ns.Publish ();
// Run this command in Terminal to see if it was added ok:
// dns-sd -Z _testservice._tcp local
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment