Re: NSDocumentController singleton problem, part 2
Re: NSDocumentController singleton problem, part 2
- Subject: Re: NSDocumentController singleton problem, part 2
- From: Brad Oliver <email@hidden>
- Date: Fri, 03 Jan 2003 15:29:53 -0600
On 12/20/02 11:59 AM, "Mike Ferris" <email@hidden> wrote:
>
I would start by overriding NSDocumentController's -openDocument: and
>
-newDocument: to do nothing if you don't want a new document (and maybe
>
-validateMenuItem: to not allow the menu choices to even be enabled
>
when you can't handle them.
>
>
That covers the menu commands. Pretty much all other means of opening
>
a new document (double-clicking, AppleScript, etc...) will consult the
>
app delegate if it implements -application:openFile:. So you can
>
implement that. If you decide to allow the open, simply call
>
NSDocumentController's --openDocumentWithContentsOfFile:display:,
>
otherwise don't. And probably return YES either way since not opening
>
a document in your case is not an error, but a "feature".
Just to follow up, this works perfect for my needs as described, with one
caveat. I needed to call back into NSDocumentController from my document
dealloc routine to finish the second half of the open/new process, otherwise
I got into a position where I had two documents present in the document
controller for a brief period, which confused some other code in my app.
Thanks all for the tips and advice!
--
Brad Oliver
email@hidden
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.