简体   繁体   English

将文件类型/扩展名与基于非文档的cocoa应用程序相关联

[英]Associate file type/extension to non document based cocoa application

This is for some reason really hard to find and solve. 由于某种原因,这很难找到和解决。 Cannot find any documentation on it. 找不到任何文档。 I've got a non-document based application which I would like to open all specific file types, but I do not want to use NSDocuments but let my code handle the opening of file and processing of it. 我有一个非基于文档的应用程序,我想打开所有特定的文件类型,但我不想使用NSDocuments但让我的代码处理文件的打开和处理它。 I've added the CFBundleTypeExtensions and all, settings to the info.plist. 我已将CFBundleTypeExtensions和所有设置添加到info.plist中。

Now the application will open the filetype but display an error like: "The document xxxx could not be opened. Application cannot open files in the yyyyy format." 现在应用程序将打开文件类型,但显示如下错误:“无法打开文档xxxx。应用程序无法以yyyyy格式打开文件。”

Have you implemented -application:openFile: in an app delegate? 你有没有实现-application:openFile:在app delegate中? If not, your application has no way of knowing how to open some random file in some random format. 如果没有,您的应用程序无法知道如何以某种随机格式打开一些随机文件。 It's up to you to add that functionality and respond with success or failure. 您可以添加该功能并响应成功或失败。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM