简体   繁体   中英

Handling **** OSType in a Cocoa NSDocument application

I have written an editor that I would like to be able to handle any file, including those with no extension.

I think that I need to add **** to the Document OS Types in my filetype entry in the Info.plist, but whereas this does allow me to drag any file to the dock icon, it doesn't attempt to open the file with the associated NSDocument class, instead telling me that my application doesn't know how to open the "SimpleText Format" format.

Any help with the step I have missed here would be greatly appreciated.

You need to implement a custom NSDocumentController subclass and override the typeForContentsOfURL:error: method, returning the name of a document type, specified by CFBundleTypeName in the application's Info.plist file

In order to make the application use your custom NSDocumentController , just drag a generic object into your MainMenu.xib file and assign it your document controller's class. The document architecture will then automatically use your document controller subclass instead of a generic NSDocumentController .

最终通过在扩展名框中创建带有*链接到相同nsdocument子类的第二个文档类型来解决此问题。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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