Using NSWorkspace selectFile:inFileViewerRootedAtPath: with files on the desktop
You can do something like this to have the finder open a window and select a file:
[[NSWorkspace sharedWorkspace] selectFile:file inFileViewerRootedAtPath:root]
This is fine for most files, but as far as I can work out, if the file is on the desktop, the Finder will still open a viewer window for it, even if you pass the path to the desktop as the root.
Has anyone worked out a way to get the Finder to simply select the file on the desktop?
Is there something sneaky that one can pass as root to convince the Finder to do 开发者_JS百科the sensible thing?
I imagine that I could write an applescript to do what I want, but I can't help feeling that there ought to be an easier way...
精彩评论