Mix & Match?
Mix & Match?
- Subject: Mix & Match?
- From: email@hidden
- Date: Wed, 28 Nov 2001 14:18:04 -0500
WARNING: Long Post! You might want a pencil and paper to follow along.
With the help of a lot of folks on this and the Project Builder lists I
have finally made some serious progress, prototyping my application in
four parts. As parts everything seems to work fine. So it is now time to
try and meld these parts into one, before I start replacing the test code
with the real deal, but there is still something I don't quite understand
concerning the document-based template and how to expand it.
To better understand the architecture of my program, imagine three columns
with four rows: Label the first column "Model," the second column
"Controller," and the third column "View." Then label the first row "Main,
" the second row "Persistent Data," the third row "Chooser," and the
fourth row "Action." Now, the Main row has no "Model," only a "Controller"
and a "View," which is a simple window with two buttons--Edit Data and
Run Program. Nothing "document-based" here that I can tell! The
Persistent Data row however must be document based as text fields can be
edited and the entries stored in an NSMutableArray. Although I have no
need whatsoever of having more that one editing window. Ever!
Now, here is where I start to have a problem: The Chooser row takes
information from the Mutable Array, preference settings, and an incoming
data feed, mixes it up with my logic (don't laugh) and presents a list of
options in the Chooser View. I don't see anything obviously
document-based here, so I'm not sure which class I should subclass for my
controller object. NSObject or NSDocument? The same goes for the Action
row: once the user makes a choice in the Chooser View, the action layer
begins its thing, which involves an on-going monitoring of the data feed
and a presentation of the progress/state in its Action View, as well as
interaction with the internet. And there may well be more than one window
involved here. Now, on the one hand I can see that these two lower layers
might be document-based in that windows are involved, sometimes more than
one, but on the other hand nothing here needs to be saved, duplicated,
printed, or any of the other stuff you typically do with "documents" like
a letter to Aunt Jane or an image of Uncle Joe.
Here is the best plan I've come up with for putting these four parts
together: I start with a document-based template and put my Main View in
the MainMenu.nib, making it visible at launch time. I use MyDocument
class and nib to implement my Persistent Data layer, since it is
definitely document based, then make my other two controllers from
NSObject with whatever NSWindowControllers I need. Does this sound right?
Am I missing something here? One thing I hope to avoid is having to
subclass NSDocumentController, which sounds way to scary.
Another question: what if I did use NSDocument instead of NSObject for the
last two controllers--would there be any down-side if NSObject would do
the job? Any and all help and/or advice eagerly awaited. Thanks in
advance.
Brian E. Howard
Cocoa Cult Central
runway in, time to start on the plane!