I want to add "Show in Finder" in my app that is similar to the one in Xcode. How do I do this using objc?
How "Show in Finder" works in Xcode?
You should:
- find the directory of the file
- then open it in Finder.
What is the issue ?
One option is to use Process.run() using open command passing the directory as the parameter. The same thing you would do in Terminal:
open ~/Documents
This will open the Documents in Finder.
The best way to do this is with activateFileViewerSelecting(_:) method on NSWorkspace. Not only is this very easy to call, it also works if your app is sandboxed.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"