开发者

How to make Finder 'Open With' work for my application (Xcode, OS X)?

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 t开发者_运维百科he 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)


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 return YES, then the framework will assume that the file wasn't opened successfully and report that fact to the user.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜