微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

objective-c – 在Finder中获取所选文件的路径

如何在Finder中检索所选文件的路径数组?

我一直在搜索,但只发现了AppleScript的链接.我也看过NSWorkspace和NSFileManager,但我没找到任何东西.

解决方法

如果可以使用AppleScript在给定的Finder窗口中获取所选文件的列表,则可以在 Cocoa应用程序中使用 Scripting Bridge与Finder进行交互.引用Apple的文档,

Scripting Bridge is a framework and a technology that makes it much easier for Cocoa developers to control and communicate with scriptable applications. Instead of incorporating AppleScript scripts in your application or dealing with the complexities of sending and handling Apple events,you can simply send Objective-C messages to an object that represents an application with a scripting interface. Your Cocoa application can do anything an AppleScript script can,but it does so in Objective-C code that is integrated with the rest of your project’s code.

没有Cocoa类代表Finder,或者更具体地说,是Finder窗口. Finder是一个应用程序,也是一个可编写脚本的应用程序,因此Scripting Bridge是最佳选择.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐