Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show in Finder not working in 10.8

This works in 10.7 but not in 10.8. How do I get this to work in Mountain Lion?

-(IBAction)showTargetInFinder:(id)sender
{

     NSString *linkPath = [targetField stringValue];
     NSWorkspace *ws = [NSWorkspace sharedWorkspace];
     [ws selectFile:linkPath inFileViewerRootedAtPath:nil];

}
like image 982
Paul Avatar asked Jan 06 '13 01:01

Paul


People also ask

How do I reveal in Finder?

With any open document, right-click (Mac: Control-click) on the Document Tab, and select “Reveal in Explorer” (Mac: “Reveal in Finder”) to open the folder that contains the file. This is a great way to locate your files on your computer!

Why Finder on Mac is not working?

If you can't make Finder work, let's give your Mac a break and restart. Go with a simple restart first. In case it won't help, restart and boot in Safe Mode: Go to the Apple menu and click Restart.

How do I see everything in Finder on Mac?

View Hidden Files in Finder In Finder, you can click your hard drive under Locations, then open your Macintosh HD folder. Press Command + Shift + . (period) to make the hidden files appear. You can also do the same from inside the Documents, Applications, and Desktop folders.


1 Answers

Use this code instead:

NSURL *fileURL = your file URL;
NSArray *fileURLs = [NSArray arrayWithObjects:fileURL, nil];
[[NSWorkspace sharedWorkspace] activateFileViewerSelectingURLs:fileURLs];

This works on 10.6+. If you want to show and select more than one file on Finder just add more NSURLs to the array and you're good to go.

like image 136
Pedro Vieira Avatar answered Oct 07 '22 12:10

Pedro Vieira