MACOS: 如何在应用程序中应用文件超链接,直接打开文件

找了很久没有很好答案:

官方给出的答案是基于共享网络协议,如smb://, afp://, 但mac 新系统已经严格控制共享文件权限,这些都不好用。


今天终于查到一个,就是用:file:///, 将路径贴在可以生成超链接的各种应用程序中,直接可以打开文件!


参考:

http://hints.macworld.com/article.php?story=20090313071515523

One way to share links to networked files
Authored by: blumenberg on Mar 23, '09 12:38:28PM

Mmh, mixed results -- I did the following things:

A) to get the filepath like:
"/Volumes/VOLUMENAME/FOLDERNAME/FILENAME"

  1. AppleScript from "ctierney": works besides "Umlaute" are garbled
  2. AppleScript from "Spartacus": no need for a list of files
  3. drag'n'drop file to a TextMate document: works besides "Umlaute" are garbled
  4. drag'n'drop file to a Terminal window: works besides spaces get escaped
  5. Contextual Menu like "haralds" (FilePathToClipCMPlugin.plugin) or FileUtilsCM.plugin w/ "copy file path": works perfect
  6. drag'n'drop file to Spotlight window ("thegooch49" tip): works perfect
and 

copy the previous copied filepath to a highlighted word via "Menu > Format > Link…" in TextEdit or Mail and add in front of the filepath "file://" -- this "linked" text is draggable to the finder and becomes a ".fileloc" file

B) or better:
"file:///Volumes/VOLUMENAME/FOLDERNAME/FILENAME"

  1. drag'n'drop file (rtf) to Firefox window : Firefox ask for download
  2. drag'n'drop folder to Firefox window : Firefox shows list/index of folder -- files and folders are links

C) or best:
"afp://BONJOURSERVERNAME.local/Volumes/VOLUMENAME/FOLDERNAME/FILENAME"

  • no readymade solution - besides:

D) combine the spotlight or the Contextual Menu tip w/ TextExpander like: prepare a snippet like "file://" (I used "flx") -- or for the additional function to mount an unmounted volume: "afp://BONJOURSERVERNAME.local" -- and put it together in Mail ("Add Link…") or TextEdit (see A))

Thinking: I'm sure there is someone who can build an AppleScript -- maybe with a dialogue -- to make this even easier


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 在 Visual Studio Code 开发 macOS 应用程序,需要创建一个 Xcode 工程文件。可以在 Xcode 使用“File > New > Project”来创建一个新的 Xcode 工程,并选择适当的模板(如 macOS > Application > Cocoa App)。然后,可以使用 Visual Studio Code 打开该工程文件夹,在其编写和调试代码。 ### 回答2: 使用VSCode开发macOS应用程序,需要创建以下工程文件: 1. Xcode工程文件(.xcodeproj或.xcworkspace):这是一个必需的文件,用于管理项目和构建应用程序。在VSCode,可以通过运行Xcode命令行工具(xcodebuild)来创建此文件,并在VSCode打开。 2. Swift源代码文件(.swift):在VSCode,可以创建和编写Swift源代码文件,用于实现应用程序的逻辑。 3. Interface Builder文件(.storyboard或.xib):这些文件用于构建用户界面,包括界面布局、视图控件和视图控制器的连接。可以使用VSCode的插件或者Xcode的可视化界面设计器来创建和编辑这些文件。 4. 图像资源文件(.png、.jpg等):用于在应用程序显示图像的资源文件。这些文件应该与Xcode工程文件一起放置在适当的目录。 5. 其他资源文件(字体、音频等):根据应用程序的需求,可能需要添加其他资源文件。这些文件也应该与Xcode工程文件一起放置在适当的目录。 在VSCode,可以使用Swift插件来提供代码编辑和调试功能。同时,还可以使用一些扩展来支持Xcode项目和工程管理,如"Swift Project Manager"等。 需要注意的是,虽然VSCode是一个功能强大的代码编辑器,但它并不直接支持创建和构建Xcode工程文件。因此,在使用VSCode进行macOS应用程序开发时,还需要同时安装和使用Xcode工具链。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值