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];
}
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!
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With