Launch Finder window with specific files selected

后端 未结 7 1381
执笔经年
执笔经年 2020-12-12 22:21

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

7条回答
  •  孤街浪徒
    2020-12-12 22:57

    Swift version:

    let paths = ["/Users/peter/foo/bar.json"]
    let fileURLs = paths.map{ NSURL(fileURLWithPath: $0)}
    NSWorkspace.sharedWorkspace().activateFileViewerSelectingURLs(fileURLs)
    

提交回复
热议问题