本文介绍了启动Finder窗口并选择了特定文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试以编程方式从Xcode项目启动OS X Finder窗口.我需要打开一个窗口到一个特定的文件夹,并自动选择该文件夹中的特定文件.
I'm trying to programmatically launch an OS X Finder window from an Xcode project. I need the window to open to a specific folder and have specific files within that folder automatically selected.
这类似于在Finder中显示";Xcode和相关应用中使用的功能.
This is similar to the "Show in Finder" functionality used in Xcode and related apps.
有人知道如何在Objective-C,Swift,AppleScript或Finder命令行参数中执行此操作吗?
Does anyone know how to do this in either Objective-C, Swift, AppleScript, or Finder command-line parameters?
推荐答案
Objective-C版本:
Objective-C version:
NSArray *fileURLs = [NSArray arrayWithObjects:fileURL1, /* ... */ nil];
[[NSWorkspace sharedWorkspace] activateFileViewerSelectingURLs:fileURLs];
这篇关于启动Finder窗口并选择了特定文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!