将文件扩展名与我的应用程序关联 [英] Associating a file extension with my application

查看:131
本文介绍了将文件扩展名与我的应用程序关联的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道如何手动将特定文件或通用扩展名与特定OS X应用程序相关联. (获取信息>打开方式>其他…)

I know how to manually associate a specific file or generic extension with a particular OS X application. (Get Info > Open with > Other…)

我知道在OS X中如何将带有扩展名的文件拖放到不支持"的应用程序上. (在应用程序上拖动时按住命令选项)

I know how, in OS X, to drag-and-drop a file with an extension onto an 'unsupported' application. (Hold down command-option when dragging over the application)

作为OS X应用程序的作者,我如何指定我的应用程序知道如何打开特定的文件扩展名?

As the author of an OS X application, how can I specify that my application knows how to open a particular file extension?

  • 我希望我的用户不需要使用命令选项进行拖放.
  • 我希望用户在选择要打开扩展程序的应用程序时,在推荐的应用程序"而不是所有应用程序"下看到我的应用程序.
  • 理想情况下,我希望用户看到具有(唯一的,尚未关联的)扩展名的文件神奇地显示正确的图标,并在将.app拖到应用程序"文件夹中后立即打开我的应用程序.
  • I want my users not to need to use command-option for drag-and-drop.
  • I want my users to see my application listed under "Recommended Applications" instead of "All Applications" when picking an app to open my extensions.
  • Ideally, I want my users to see files with my (unique, not-already-associated) extension magically show the correct icon and open with my application as soon as the .app is dragged into the Applications folder.

我已经看到 "MacOSX-与应用程序关联的文件扩展名-以编程方式" ,但我不想让用户在安装后运行安装程序或Shell脚本.

I have seen "MacOSX - File extension associate with application - Programatically", but I do not want to have to have users run an installer or shell script after installation.

推荐答案

要声明其对文件类型的支持,您的应用必须包含

To declare its support for file types, your app must include the CFBundleDocumentTypes key in its Info.plist

然后执行

- application:openFile: (for single file drag-drop)
or
- application:openFiles: (multiple files drag-drop)

查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆