views:

74

answers:

1

I have an application that has the Viewer role for PDF files. Although my application does not edit the PDF files, it does allow the user to save the PDF file (if it is too large or complex for the workflow that my application handles).

When the SaveDocumentAs: method is called, I get the following warning:

Trying to save a document without any appropriate writable type defined.

I can avoid this warning, by changing my application's role to Editor, but do not want to make my application an editor, as the application attempts to create a blank PDF document when launched.

How can I avoid this warning without declaring my application to be an Editor for PDF files?

+3  A: 

If you want to save with the document mechanism, you'll have to have the Editor role - that's my understanding. One simple way to have an editor role without creating a blank document on launch is to use the NSApplication delegate method:

-applicationShouldOpenUntitledFile:

Your answer to that delegate method, of course, would be "NO".

Joshua Nozzi
In other words, Randall, your app *is* an editor—it just can't create new documents. You should also subclass NSDocumentController and override methods there to prevent the user from *explicitly* creating new PDF documents (in addition to removing the New menu item, if your application can't create anything).
Peter Hosey
I suppose that's true, since AppleScript lends basic "new document" functionality to all document-based applications, is that right? So removing the menu wouldn't quite be enough.
Joshua Nozzi
I had removed every way for the user to create a new document, but if the app was opened by double-clicking it, it would create a new blank untitled document. I'm not concerned about a user scripting the application--if they are at the point of doing that, they know enough about how it works to know not to do that. Thanks for the answer.
Randall