【发布时间】:2013-07-20 11:56:56
【问题描述】:
在我的 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,以便我可以对这些文件执行操作。
【问题讨论】:
标签: objective-c macos cocoa finder