Implementing "Show in Finder" button in Objective-C

Its worth mentioning that owen's method only works from osx 10.6 or later (Ref: https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSWorkspace_Class/Reference/Reference.html ).

So if your writing something to run on the older generations its probably better to do it in the way suggested by justin as its not been deprecated (yet).


NSArray *fileURLs = [NSArray arrayWithObjects:fileURL1, /* ... */ nil];
[[NSWorkspace sharedWorkspace] activateFileViewerSelectingURLs:fileURLs];

stolen from Launch OSX Finder window with specific files selected


You can use NSWorkspace method -selectFile:inFileViewerRootedAtPath: like this:

[[NSWorkspace sharedWorkspace] selectFile:fullPathString inFileViewerRootedAtPath:pathString];