I have an application I'm developing in cocoa, and I have a problem with NSPathControl.
I set the style of the control to Popup, and when I launch my App and click on the path control, it shows me a popup menu with the components of the URL I set. I.e., for URL like file://localhost/Applications/Games/ it shows me the following: My Macbook, Macintosh HD, Applications, Games.
Now, when I click on Applications, I receive an action, and whithin that action [[sender clickedPathComponentCell] URL] returns correct URL: file://localhost/Applications/.
Problem 1:
But when I click on Macintosh HD, I get an URL with double trailing slash: file://localhost//.
Problem 2: is that I get the same URL file://localhost// when I click on My Macbook item. So, I have 2 questions:
Why does the URL to
Macintosh HDends with double slash?How can I distinguish clicks on
Macintosh HDandMy Macbook, and what is the correct URL toMy Macbook, where Finder shows the list of mounted volumes (on my macbook it isMacintosh HDandBOOTCAMP)?
I've examined the tutorial named "SourceView", but there was no item like My Macbook, so I was not able to find out, whether My Macbook is really exists as a some kind of virtual folder, or I should just use NSFileManager to get the list of mounted volumes.
Problem #1:
The URL is
file://localhost//because the path to your boot volume is/. It's a bit odd, butfile://localhost/(single slash) would mean "a file on localhost with no path", so you getfile://localhost//(double slash) to mean "a file on localhost at path/.You shouldn't really have to worry about the eccentricities of the URL you're getting - just pass it along to whatever needs it and it should deal with it just fine.
Problem #2:
"My MacBook" doesn't really exist - it's a virtual folder that shows the list of connected volumes,
/Network, etc. There's isn't a valid path for it since it doesn't exist, so instead you get the path to your boot volume instead.