iPhone SDK: Bonjour & NSNetService name != published name?

Posted by Harkonian on Stack Overflow See other posts from Stack Overflow or by Harkonian
Published on 2010-05-26T14:39:57Z Indexed on 2010/05/26 14:41 UTC
Read the original article Hit count: 347

Filed under:
|
|

In my iPhone app, I'm publishing a bonjour service and using the following delegate method:

- (void)netServiceDidPublish:(NSNetService *)ns
{
   NSLog(@"Bonjour Service Published: http://%@.%@", [ns name], [ns domain]);
}

The "name" property is returning the device name, "How's Testing", which is correct. However, when I use Safari to discover available services the name is "hows-testing" -- the service is http://hows-testing.local.:>.

Why is the published name different than what is being reported by the NSNetService? How do I display for the actual name of the published service? Assuming that, for some reason, there is no way to get the published name from the object, how do I determine it myself? I understand that it's based on device name, but what are the substitution rules? Remove apostrophes, replace spaces with dash...anything else? What about special characters?

© Stack Overflow or respective owner

Related posts about iphone-sdk

Related posts about cocoa