Cocoa (or any Mac API) "browse for computer" dialog
Cocoa (or any Mac API) "browse for computer" dialog
- Subject: Cocoa (or any Mac API) "browse for computer" dialog
- From: Dan Korn <email@hidden>
- Date: Thu, 08 May 2014 09:02:13 -0700
- Acceptlanguage: en-US
- Thread-topic: Cocoa (or any Mac API) "browse for computer" dialog
I thought this would be pretty easy, but I’m having a heck of a time figuring out how to present a dialog to the user to select (choose) from a list of computers on the network.
In the Finder, or in a file dialog in any application, I can just select “Network”, or click on “All…” under “SHARED” in the sidebar, to see a list of servers on the LAN (although I can’t seem to select a computer name in a file dialog, only expand it to see shared folders). But I don’t see how to do this in a dialog that I can call from my own application.
On Windows, this is easy enough with a call to SHBrowseForFolder with the BIF_BROWSEFORCOMPUTER flag and the CSIDL_NETWORK location. So there must be a way to do something similar on Mac, right?
Even if it can’t be done with NSOpenPanel, I would take a list of computers to put into a popup menu. I’ve been scouring the docs for Bonjour, and for NSOpenPanel and other Cocoa classes, and I’ve found some constants such as NSNetworkDomainMask and classes like NSNetServiceBrowser, but I can’t figure out how to put these together to get just a list of servers. I’ve even tried variations of commands like netstat and arp in the Terminal, trying to find the equivalent of “net view” on Windows, but nothing seems to show that same list of servers that the Finder shows as “Network”.
Surely someone must have done something like this before. Any hints? Cocoa, Carbon, bash/system command, even AppleScript solutions are welcome.
Thanks,
Dan
P.S. Posting to Xcode-Users as it’s not necessarily a Cocoa-specific question.
P.P.S. I’ve also received the "Your membership in the mailing list Xcode-users has been disabled due to excessive bounces” emails, and replied to them as instructed, only to receive "Invalid confirmation string” in return. I had to go to the web interface to re-activate email delivery. Mods, please fix!
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden