Duncan
Duncan

Reputation: 453

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.

Upvotes: 0

Views: 313

Answers (2)

Duncan
Duncan

Reputation: 453

Solved this eventually by creating a second document type linked to the same nsdocument subclass with * in the extensions box.

Upvotes: 0

Rob Keniger
Rob Keniger

Reputation: 46028

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.

Upvotes: 1

Related Questions