如何让 Finder “打开方式”适用于我的应用程序(Xcode、OS X)吗?
我创建了一个能够播放音频文件的应用程序。这本身工作得很好,从查找器拖放到我的应用程序也是如此。
我还希望人们可以使用“打开方式”菜单从 Finder 中使用我的应用程序(甚至允许他们将我的应用程序设置为某种文件类型的默认应用程序)
经过大量搜索后,我发现我应该配置Xcode 中的文档类型 (编辑信息属性列表) 我成功添加了一个名为“音乐文件”的类型,UTI为“public.mp3” 现在,当我右键单击 MP3 文件时,我的应用程序会列在“打开方式”菜单中。 尝试使用它,我的应用程序打开,但收到一条警告消息,显示“无法打开文档。应用程序无法打开“音乐文件”格式的文件”
它似乎没有按原样通过命令行传递Windows 中的情况。 我的应用程序确实支持从 Finder 中进行拖放,而且效果也很好。
我真的不知道下一步该去哪里,所以如果有人能指出我正确的方向,那就太好了。 我的应用程序不使用 NSDocument,因此我认为“Class”字段不适用于我(根据文档,该字段不是必需的,但它没有说明如何在没有类的情况下处理它)
I have created an application that is capable of playing audio files. This in itself works fine, and so does drag&drop from finder to my application.
What I would like as well, is that people can use my application from Finder using the Open With menu (or even allow them to set my application as default for a certain file type)
After a lot of searching, I found that I should configure a document type in Xcode (Editing information property lists)
I successfully added such a type named 'Music File', with UTI 'public.mp3'
When I now right-click an MP3 file, my application is listed in the 'Open With' menu.
Trying to use it, my app opens, but I get a warning message saying "The document could not be opened. App cannot open files in the 'Music File' format"
It doesn't appear to be passed through the command line as is the case in Windows.
My application does support drag&drop from Finder, and this is working fine too.
I don't really know where to look next, so it would be great if anyone could point me in the right direction.
My application isn't using NSDocument, so the 'Class' field doesn't apply for me I think (and according to the docs this field isn't required, but it doesn't say how to handle it without a Class)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否实施
application:openFile:
在你的应用程序委托中?当您的应用程序被要求从 Finder 打开文件时,将调用此方法。如果未实现或未返回YES
,则框架将假定文件未成功打开并向用户报告该事实。Do you implement
application:openFile:
in your app delegate? This is the method that will be called when your application is asked to open a file from the Finder. If it's not implemented or doesn't returnYES
, then the framework will assume that the file wasn't opened successfully and report that fact to the user.