Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tatsuro-ueda/3411315 to your computer and use it in GitHub Desktop.
Save tatsuro-ueda/3411315 to your computer and use it in GitHub Desktop.
iOSからBonjourを見つけるためのコード
- (void)netServiceBrowser:(NSNetServiceBrowser *)aNetServiceBrowser
didFindService:(NSNetService *)aNetService
moreComing:(BOOL)moreComing
{
// HTTPサービスのうちCocoaHTTPServerという名前のサービスだけを探す
if (!_desktopServer && [aNetService.name isEqualToString:@"CocoaHTTPServer"]) {
_desktopServer = [[NSNetService alloc] initWithDomain:[aNetService domain]
type:[aNetService type]
name:[aNetService name]];
[_desktopServer resolveWithTimeout:30];
_desktopServer.delegate = self;
self.statusLabel.text = @"Resolving CocoaHTTPServer...";
NSLog(@"%@", _desktopServer);
}
else {
NSLog(@"ignoring %@", aNetService);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment