作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在我的 Cocoa 应用程序中,我尝试检索在 Finder 窗口中选择的文件列表。我找到了以下方法来做到这一点,但是速度慢得难以忍受。
FinderApplication * finder =
[SBApplication applicationWithBundleIdentifier:@"com.apple.finder"];
SBElementArray * selection = [[finder selection] get];
NSArray<NSString*> * items = [selection arrayByApplyingSelector:@selector(URL)];
// now items contains the URLs as strings of all selected items
从时间角度来看,最昂贵的通话是
SBElementArray * selection = [[finder selection] get];
当对大量文件进行选择时,该方法会长时间挂起,甚至在处理少量文件时也表现不佳。
是否有更好的方法来获取最前面的 Finder 窗口中所有选定文件的 URL?
我需要文件 URL,以便我可以对这些文件执行操作。
最佳答案
您可以使用苹果脚本
tell application "Finder"
get selection
end tell
或
osascript -e "tell application \"Finder\" to return selection"
关于objective-c - 如何在 Finder 中检索所选项目的列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17775884/
我正在尝试用 Swift 编写这段 JavaScript 代码:k_combinations 到目前为止,我在 Swift 中有这个: import Foundation import Cocoa e
我是一名优秀的程序员,十分优秀!