Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Implementing "Show in Finder" button in Objective-C

Tags:

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?

like image 506
Locksleyu Avatar asked May 23 '12 15:05

Locksleyu


2 Answers

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

stolen from Launch OSX Finder window with specific files selected

like image 99
owen gerig Avatar answered Oct 05 '22 09:10

owen gerig


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

[[NSWorkspace sharedWorkspace] selectFile:fullPathString inFileViewerRootedAtPath:pathString]; 
like image 35
Justin Boo Avatar answered Oct 05 '22 09:10

Justin Boo