Re: Document Architecture question - newbie
Re: Document Architecture question - newbie
- Subject: Re: Document Architecture question - newbie
- From: Bill Bumgarner <email@hidden>
- Date: Thu, 27 Oct 2005 10:44:59 -0700
On Oct 25, 2005, at 8:00 PM, Doug wrote:
I have an idea for an application that would use the
Cocoa Multiple Document Architecture. A document
would have a window to display data, but that data
would be from multiple files that could each be opened
as an independent (and different) document window:
Doc (file A)
/
Main Doc (file X) - Doc (file B)
\
Doc (file C)
I need some help understanding where to start. I know
that NSDocument needs to be subclassed for each type
of doc, I assume NSWindowController will need to be
subclassed to provide the "file management" for the
main doc. Is that generally the idea?? Thanks.
First, let me rephrase want you want:
You have an application with a single Document type where each opened
Document may have multiple Windows of different types?
If that is an accurate description, then you will want a single
subclass of NSDocument and multiple subclasses of
NSWindowController. The NSDocument infrastructure has methods that
can be overridden to connect multiple NSWindowController (or
subclasses) to the document.
I have always found it slightly unfortunate that there isn't a Cocoa
multiple document application template that demonstrates the use of a
window controller. The window controller is where your toolbar
code, etc, should go while the document is where the, well, document
code should go.
In any case, read the NSDocument and NSWindowController documentation
and the related concepts guides. Assuming I interpreted what you
are asking for correctly, NSDocument is designed to support exactly
such a configuration.
The only other trick to all of this is where to put the various
controllers (ArrayController, ObjectController, and TreeController)
such that the various document windows will correctly track
selection, etc. If you have a "main" window, then stick 'em in
there. The "auxillary" windows can then have bindings through paths
that lead to the "main" window through the file's owner. This
paragraph will make no sense until you have a solid understanding of
NSDocument's interaction with the window controller, controllers, and
keypaths.
b.bum
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden