Implementing "Show in Finder" button in Objective-C

Locksleyu picture Locksleyu · May 23, 2012 · Viewed 7.5k times · Source

In my application I would like to create a 'Show in Finder' button.

Show in Finder in Xcode

I have been able to figure out how to pop up a Finder window of that directory but haven't figured out how to highlight the file like the OS does.

Is this possible?

Answer

owen gerig picture owen gerig · May 23, 2012
NSArray *fileURLs = [NSArray arrayWithObjects:fileURL1, /* ... */ nil];
[[NSWorkspace sharedWorkspace] activateFileViewerSelectingURLs:fileURLs];

stolen from Launch OSX Finder window with specific files selected